summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPekka Paalanen <pekka.paalanen@collabora.co.uk>2015-03-24 15:56:20 +0200
committerPekka Paalanen <pekka.paalanen@collabora.co.uk>2015-03-27 09:38:19 +0200
commit8a0e0ba66ace54062880d4bd9fbdd508ee9d3589 (patch)
tree51a860e9b65d7fe3a3fc794d436f79e60e0a3d48
parent6c71aaeec5d034e052c9d95f3c36b5b38069f6d8 (diff)
compositor: add option to specify a weston.ini
Add a command line option to specify a file to be read instead of weston.ini. IVI-shell testing will at least temporarily need to specify a config file, because it cannot run without. That is why this is being added, but should be convenient for everybody, too. 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>
-rw-r--r--man/weston.man12
-rw-r--r--src/compositor.c29
2 files changed, 35 insertions, 6 deletions
diff --git a/man/weston.man b/man/weston.man
index 86ed67be..c5dc2f20 100644
--- a/man/weston.man
+++ b/man/weston.man
@@ -111,6 +111,18 @@ or you can pass an absolute path. The default backend is
unless the environment suggests otherwise, see
.IR DISPLAY " and " WAYLAND_DISPLAY .
.TP
+\fB\-\^c\fR\fIconfig.ini\fR, \fB\-\-config\fR=\fIconfig.ini\fR
+Load
+.IR config.ini " instead of " weston.ini .
+The argument can also be an absolute path starting with a
+.IR / .
+If the path is not absolute, it will be searched in the normal config
+paths, see
+.BR weston.ini (5).
+If also
+.B --no-config
+is given, no configuration file will be read.
+.TP
.BR \-\-version
Print the program version.
.TP
diff --git a/src/compositor.c b/src/compositor.c
index 3a90cce2..4de8fbf5 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -5213,25 +5213,39 @@ weston_transform_to_string(uint32_t output_transform)
}
static int
-load_configuration(struct weston_config **config, int32_t noconfig)
+load_configuration(struct weston_config **config, int32_t noconfig,
+ const char *config_file)
{
+ const char *file = "weston.ini";
const char *full_path;
*config = NULL;
+ if (config_file)
+ file = config_file;
+
if (noconfig == 0)
- *config = weston_config_parse("weston.ini");
+ *config = weston_config_parse(file);
if (*config) {
full_path = weston_config_get_full_path(*config);
weston_log("Using config file '%s'\n", full_path);
setenv(WESTON_CONFIG_FILE_ENV_VAR, full_path, 1);
- } else {
- weston_log("Starting with no config file.\n");
- setenv(WESTON_CONFIG_FILE_ENV_VAR, "", 1);
+
+ return 0;
}
+ if (config_file && noconfig == 0) {
+ weston_log("fatal: error opening or reading config file"
+ " '%s'.\n", config_file);
+
+ return -1;
+ }
+
+ weston_log("Starting with no config file.\n");
+ setenv(WESTON_CONFIG_FILE_ENV_VAR, "", 1);
+
return 0;
}
@@ -5259,6 +5273,7 @@ int main(int argc, char *argv[])
int32_t version = 0;
int32_t noconfig = 0;
int32_t numlock_on;
+ char *config_file = NULL;
struct weston_config *config;
struct weston_config_section *section;
struct wl_client *primary_client;
@@ -5275,6 +5290,7 @@ int main(int argc, char *argv[])
{ WESTON_OPTION_BOOLEAN, "help", 'h', &help },
{ WESTON_OPTION_BOOLEAN, "version", 0, &version },
{ WESTON_OPTION_BOOLEAN, "no-config", 0, &noconfig },
+ { WESTON_OPTION_STRING, "config", 'c', &config_file },
};
parse_options(core_options, ARRAY_LENGTH(core_options), &argc, argv);
@@ -5316,7 +5332,7 @@ int main(int argc, char *argv[])
if (!signals[0] || !signals[1] || !signals[2] || !signals[3])
goto out_signals;
- if (load_configuration(&config, noconfig) < 0)
+ if (load_configuration(&config, noconfig, config_file) < 0)
goto out_signals;
section = weston_config_get_section(config, "core", NULL, NULL);
@@ -5436,6 +5452,7 @@ out_signals:
weston_log_file_close();
+ free(config_file);
free(backend);
free(shell);
free(socket_name);