[PATCH weston 6/6] compositor: add option to specify a weston.ini
Pekka Paalanen
ppaalanen at gmail.com
Tue Mar 24 06:56:20 PDT 2015
From: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
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 at collabora.co.uk>
---
man/weston.man | 12 ++++++++++++
src/compositor.c | 29 +++++++++++++++++++++++------
2 files changed, 35 insertions(+), 6 deletions(-)
diff --git a/man/weston.man b/man/weston.man
index 86ed67b..c5dc2f2 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 7d5c2e1..55a3091 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -5211,25 +5211,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;
}
@@ -5257,6 +5271,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;
@@ -5273,6 +5288,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);
@@ -5314,7 +5330,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);
@@ -5434,6 +5450,7 @@ out_signals:
weston_log_file_close();
+ free(config_file);
free(backend);
free(shell);
free(socket_name);
--
2.0.5
More information about the wayland-devel
mailing list