[PATCH 1/1] config: add command line option for config file

Eoff, Ullysses A ullysses.a.eoff at intel.com
Thu Sep 26 13:00:39 PDT 2013


This patch only instructs the main compositor process to use the command-line specified
configuration file.  What about the other things that depend on settings from the configuration
file: window.c, tablet-shell.c, desktop-shell.c, and terminal.c? Those all load "weston.ini" using
the default path resolution and therefore won't be loading the settings from the command-line
specified configuration file.

Also, I think the default resolution for weston.ini is in ${XDG_CONFIG_HOME}/,
${HOME}/.config/, ${XDG_CONFIG_DIRS}/, and finally ${PWD}/.  The help message in this patch
says it defaults to ${PWD}/ which is deceiving. 

-- U. Artie

> -----Original Message-----
> From: wayland-devel-bounces+ullysses.a.eoff=intel.com at lists.freedesktop.org [mailto:wayland-devel-
> bounces+ullysses.a.eoff=intel.com at lists.freedesktop.org] On Behalf Of Alex DAMIAN
> Sent: Thursday, September 26, 2013 2:27 AM
> To: wayland-devel at lists.freedesktop.org
> Cc: Damian, Alexandru
> Subject: [PATCH 1/1] config: add command line option for config file
> 
> From: Alexandru DAMIAN <alexandru.damian at intel.com>
> 
> Added an option to specify the weston.ini config file
> to be used. Defaults to ${PWD}/weston.ini
> 
> Adding a check in weston_config_full_path so that
> we don't crash if we started without a config file.
> 
> Fixing a typo in help message.
> 
> Signed-off-by: Alexandru DAMIAN <alexandru.damian at intel.com>
> ---
>  shared/config-parser.c |  2 +-
>  src/compositor.c       | 15 +++++++++++----
>  2 files changed, 12 insertions(+), 5 deletions(-)
> 
> diff --git a/shared/config-parser.c b/shared/config-parser.c
> index e1bf212..8defbbb 100644
> --- a/shared/config-parser.c
> +++ b/shared/config-parser.c
> @@ -385,7 +385,7 @@ weston_config_parse(const char *name)
>  const char *
>  weston_config_get_full_path(struct weston_config *config)
>  {
> -	return config->path;
> +	return config == NULL ? NULL : config->path;
>  }
> 
>  int
> diff --git a/src/compositor.c b/src/compositor.c
> index f619f82..c073410 100644
> --- a/src/compositor.c
> +++ b/src/compositor.c
> @@ -3338,7 +3338,8 @@ usage(int error_code)
>  		"  -S, --socket=NAME\tName of socket to listen on\n"
>  		"  -i, --idle-time=SECS\tIdle time in seconds\n"
>  		"  --modules\t\tLoad the comma-separated list of modules\n"
> -		"  --log==FILE\t\tLog to the given file\n"
> +		"  --log=FILE\t\tLog to the given file\n"
> +		"  --config=FILE\t\tUse specified config file. Defaults to ./weston.ini\n"
>  		"  -h, --help\t\tThis help message\n\n");
> 
>  	fprintf(stderr,
> @@ -3429,6 +3430,7 @@ int main(int argc, char *argv[])
>  	int32_t help = 0;
>  	char *socket_name = "wayland-0";
>  	int32_t version = 0;
> +	char *config_file = "weston.ini";
>  	struct weston_config *config;
>  	struct weston_config_section *section;
> 
> @@ -3441,6 +3443,7 @@ int main(int argc, char *argv[])
>  		{ WESTON_OPTION_STRING, "log", 0, &log },
>  		{ WESTON_OPTION_BOOLEAN, "help", 'h', &help },
>  		{ WESTON_OPTION_BOOLEAN, "version", 0, &version },
> +		{ WESTON_OPTION_STRING, "config", 'c', &config_file },
>  	};
> 
>  	parse_options(core_options, ARRAY_LENGTH(core_options), &argc, argv);
> @@ -3488,9 +3491,13 @@ int main(int argc, char *argv[])
>  			backend = WESTON_NATIVE_BACKEND;
>  	}
> 
> -	config = weston_config_parse("weston.ini");
> -	weston_log("Using config file '%s'\n",
> -		   weston_config_get_full_path(config));
> +	config = weston_config_parse(config_file);
> +
> +	if (config != NULL) {
> +		weston_log("Using config file '%s'\n", weston_config_get_full_path(config));
> +	} else {
> +		weston_log("Starting with no config file.");
> +	}
>  	section = weston_config_get_section(config, "core", NULL, NULL);
>  	weston_config_section_get_string(section, "modules", &modules, "");
> 
> --
> 1.8.1.2
> 
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel


More information about the wayland-devel mailing list