daemon: add cmdline option to load custom profile and report error if not found

This commit is contained in:
George Kiagiadakis 2023-12-18 17:58:09 +02:00
parent c0b212bb0e
commit 0037733545
2 changed files with 16 additions and 3 deletions

View file

@ -739,8 +739,16 @@ wp_internal_comp_loader_load (WpComponentLoader * self, WpCore * core,
profile_json =
wp_conf_get_value (conf, "wireplumber.profiles", component, NULL);
if (profile_json)
wp_properties_update_from_json (profile, profile_json);
if (!profile_json) {
g_autoptr (GTask) task = g_task_new (self, cancellable, callback, data);
g_task_set_source_tag (task, wp_internal_comp_loader_load);
g_task_return_new_error (G_TASK (task), WP_DOMAIN_LIBRARY,
WP_LIBRARY_ERROR_INVALID_ARGUMENT,
"profile '%s' not found in configuration", component);
return;
}
wp_properties_update_from_json (profile, profile_json);
components = wp_conf_get_section (conf, "wireplumber.components", NULL);

View file

@ -25,6 +25,7 @@ enum WpExitCode
static gboolean show_version = FALSE;
static gchar * config_file = NULL;
static gchar * profile = NULL;
static GOptionEntry entries[] =
{
@ -32,6 +33,8 @@ static GOptionEntry entries[] =
"Show version", NULL },
{ "config-file", 'c', G_OPTION_FLAG_NONE, G_OPTION_ARG_STRING, &config_file,
"The context configuration file", NULL },
{ "profile", 'p', G_OPTION_FLAG_NONE, G_OPTION_ARG_STRING, &profile,
"The profile to load", NULL },
{ NULL }
};
@ -151,6 +154,8 @@ main (gint argc, gchar **argv)
if (!config_file)
config_file = "wireplumber.conf";
if (!profile)
profile = "main";
/* Forward WIREPLUMBER_CONFIG_DIR to PIPEWIRE_CONFIG_DIR */
conf_env = g_getenv ("WIREPLUMBER_CONFIG_DIR");
@ -161,7 +166,7 @@ main (gint argc, gchar **argv)
PW_KEY_CONFIG_NAME, config_file,
PW_KEY_APP_NAME, "WirePlumber",
"wireplumber.daemon", "true",
"wireplumber.profile", "main",
"wireplumber.profile", profile,
NULL);
/* prefer manager socket */