Pass config file from compositor to everything

We have the Weston command line option '--no-config' which is meant to
prevent loading weston.ini at all. It works for Weston itself, but it
does not work for any clients that also want to read weston.ini.

To fix that, introduce a new environment variable WESTON_CONFIG_FILE.
Weston will set it to the absolute path of the config file it loads.
Clients will load the config file pointed to by WESTON_CONFIG_FILE. If
the environment variable is set but empty, no config file will be
loaded. If the variable is unset, things fall back to the default
"weston.ini".

Note, that Weston will only set WESTON_CONFIG_FILE, it never reads it.
The ability to specify a custom config file to load will be another patch.

All programs that loaded "weston.ini" are modified to honour
WESTON_CONFIG_FILE.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
Reviewed-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
This commit is contained in:
Pekka Paalanen
2015-03-24 15:56:19 +02:00
parent dc940caae5
commit 6c71aaeec5
8 changed files with 45 additions and 6 deletions
+12
View File
@@ -294,6 +294,18 @@ weston_config_get_libexec_dir(void)
return LIBEXECDIR;
}
const char *
weston_config_get_name_from_env(void)
{
const char *name;
name = getenv(WESTON_CONFIG_FILE_ENV_VAR);
if (name)
return name;
return "weston.ini";
}
static struct weston_config_section *
config_add_section(struct weston_config *config, const char *name)
{
+5
View File
@@ -27,6 +27,8 @@
extern "C" {
#endif
#define WESTON_CONFIG_FILE_ENV_VAR "WESTON_CONFIG_FILE"
enum config_key_type {
CONFIG_KEY_INTEGER, /* typeof data = int */
CONFIG_KEY_UNSIGNED_INTEGER, /* typeof data = unsigned int */
@@ -95,6 +97,9 @@ weston_config_section_get_bool(struct weston_config_section *section,
const char *
weston_config_get_libexec_dir(void);
const char *
weston_config_get_name_from_env(void);
struct weston_config *
weston_config_parse(const char *name);