[PATCH weston sdk v2 7/8] weston.ini: Allow a relative path for screensaver

Quentin Glidic sardemff7+wayland at sardemff7.net
Mon Jul 1 08:03:07 PDT 2013


From: Quentin Glidic <sardemff7+git at sardemff7.net>

Signed-off-by: Quentin Glidic <sardemff7+git at sardemff7.net>
---
 man/weston.ini.man | 3 ++-
 src/shell.c        | 9 ++++++++-
 weston.ini         | 2 +-
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/man/weston.ini.man b/man/weston.ini.man
index f457d34..4141e77 100644
--- a/man/weston.ini.man
+++ b/man/weston.ini.man
@@ -205,11 +205,12 @@ The
 section is optional, as are all of the entries that may be specified in
 it.
 .TP 7
-.BI "path=" /usr/libexec/weston-screensaver
+.BI "path=" /usr/libexec/weston/weston-screensaver
 This instructs the compositor to use the selected screensaver client on a given
 path (string). If this line is missing or commented out, the screensaver in
 .B "weston(1)"
 is disabled.
+May be relative to __weston_libexec_dir__.
 .RE
 .TP 7
 .BI "duration=" 600
diff --git a/src/shell.c b/src/shell.c
index 0c11e22..9ea87dc 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -27,6 +27,7 @@
 #include <stdio.h>
 #include <stdbool.h>
 #include <string.h>
+#include <limits.h>
 #include <unistd.h>
 #include <linux/input.h>
 #include <assert.h>
@@ -388,12 +389,18 @@ shell_configuration(struct desktop_shell *shell)
 {
 	struct weston_config_section *section;
 	int duration;
-	char *s;
+	char *s, path[PATH_MAX];
 
 	section = weston_config_get_section(shell->compositor->config,
 					    "screensaver", NULL, NULL);
 	weston_config_section_get_string(section,
 					 "path", &shell->screensaver.path, NULL);
+	if (shell->screensaver.path != NULL &&
+	    shell->screensaver.path[0] != '/') {
+		snprintf(path, sizeof path, "%s/%s", PKGLIBEXECDIR, shell->screensaver.path);
+		free(shell->screensaver.path);
+		shell->screensaver.path = strdup(path);
+	}
 	weston_config_section_get_int(section, "duration", &duration, 60);
 	shell->screensaver.duration = duration * 1000;
 
diff --git a/weston.ini b/weston.ini
index a9ddbc9..7fa60a4 100644
--- a/weston.ini
+++ b/weston.ini
@@ -36,7 +36,7 @@ path=./clients/flower
 
 [screensaver]
 # Uncomment path to disable screensaver
-path=/usr/libexec/weston-screensaver
+path=weston-screensaver
 duration=600
 
 [input-method]
-- 
1.8.3.1



More information about the wayland-devel mailing list