diff --git a/src/main.c b/src/main.c index 9b39ab23..9e866c2d 100644 --- a/src/main.c +++ b/src/main.c @@ -327,6 +327,22 @@ init_done (WpCore * core, GAsyncResult * res, WpDaemon * d) } } +static gchar * +find_config (const gchar *config_file_name) +{ + g_autofree gchar *path = NULL; + + if (!config_file_name) + config_file_name = "wireplumber.conf"; + + if (g_path_is_absolute (config_file_name)) + path = g_strdup (config_file_name); + else + path = g_build_filename (wp_get_config_dir (), config_file_name, NULL); + + return g_canonicalize_filename (path, NULL); +} + gint main (gint argc, gchar **argv) { @@ -334,6 +350,7 @@ main (gint argc, gchar **argv) g_autoptr (GOptionContext) context = NULL; g_autoptr (GError) error = NULL; g_autoptr (WpProperties) properties = NULL; + g_autofree gchar *config_file_path = NULL; wp_init (WP_INIT_ALL); @@ -344,22 +361,15 @@ main (gint argc, gchar **argv) return WP_EXIT_USAGE; } + config_file_path = find_config (config_file); + properties = wp_properties_new ( - PW_KEY_CONFIG_NAME, config_file ? config_file : "wireplumber.conf", + PW_KEY_CONFIG_NAME, config_file_path, PW_KEY_APP_NAME, "WirePlumber", "wireplumber.daemon", "true", "wireplumber.export-core", "true", NULL); - if (!g_path_is_absolute (wp_get_config_dir ())) { - g_autofree gchar *cwd = g_get_current_dir (); - g_autofree gchar *conf_dir = - g_build_filename (cwd, wp_get_config_dir (), NULL); - wp_properties_set (properties, PW_KEY_CONFIG_PREFIX, conf_dir); - } else { - wp_properties_set (properties, PW_KEY_CONFIG_PREFIX, wp_get_config_dir ()); - } - /* init wireplumber daemon */ d.loop = g_main_loop_new (NULL, FALSE); d.core = wp_core_new (NULL, g_steal_pointer (&properties));