summaryrefslogtreecommitdiff
path: root/shared
diff options
context:
space:
mode:
authorPekka Paalanen <pekka.paalanen@collabora.co.uk>2015-03-24 15:56:19 +0200
committerPekka Paalanen <pekka.paalanen@collabora.co.uk>2015-03-27 09:38:12 +0200
commit6c71aaeec5d034e052c9d95f3c36b5b38069f6d8 (patch)
tree6a5d8b4cebb294d03b583e891553c5fcffc26cff /shared
parentdc940caae54ee8a631a30d76b54b209dab322d12 (diff)
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>
Diffstat (limited to 'shared')
-rw-r--r--shared/config-parser.c12
-rw-r--r--shared/config-parser.h5
2 files changed, 17 insertions, 0 deletions
diff --git a/shared/config-parser.c b/shared/config-parser.c
index ff6814ce..8519eb68 100644
--- a/shared/config-parser.c
+++ b/shared/config-parser.c
@@ -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)
{
diff --git a/shared/config-parser.h b/shared/config-parser.h
index 1ecc8cc2..9b766193 100644
--- a/shared/config-parser.h
+++ b/shared/config-parser.h
@@ -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);