shell: use desktop-shell ini file for screensaver path
Read the same configuration file in the shell plugin (desktop-shell) as
the desktop-shell client does.
Add a new section "screensaver", where "path" defines the path of the
idle animation client to be executed. Not defining "path" disables the
animation.
Idle animations are not in use by default. It must be configured in
wayland-desktop-shell.ini or launched manually.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
diff --git a/compositor/Makefile.am b/compositor/Makefile.am
index 6716446..ce5a3d2 100644
--- a/compositor/Makefile.am
+++ b/compositor/Makefile.am
@@ -74,7 +74,8 @@
if ENABLE_DESKTOP_SHELL
desktop_shell = desktop-shell.la
desktop_shell_la_LDFLAGS = -module -avoid-version
-desktop_shell_la_LIBADD = $(COMPOSITOR_LIBS)
+desktop_shell_la_LIBADD = $(COMPOSITOR_LIBS) \
+ ../shared/libconfig-parser.la
desktop_shell_la_CFLAGS = $(GCC_CFLAGS)
desktop_shell_la_SOURCES = \
shell.c \
diff --git a/compositor/shell.c b/compositor/shell.c
index 99c2af5..6cabcfc 100644
--- a/compositor/shell.c
+++ b/compositor/shell.c
@@ -33,6 +33,7 @@
#include <wayland-server.h>
#include "compositor.h"
#include "desktop-shell-server-protocol.h"
+#include "../shared/config-parser.h"
struct shell_surface;
@@ -57,6 +58,7 @@
struct wl_list panels;
struct {
+ const char *path;
struct wl_resource *binding;
struct wl_list surfaces;
struct wlsc_process process;
@@ -95,6 +97,28 @@
int32_t dx, dy;
};
+static int
+shell_configuration(struct wl_shell *shell)
+{
+ int ret;
+ char *config_file;
+
+ struct config_key saver_keys[] = {
+ { "path", CONFIG_KEY_STRING, &shell->screensaver.path },
+ };
+
+ struct config_section cs[] = {
+ { "screensaver", saver_keys, ARRAY_LENGTH(saver_keys), NULL },
+ };
+
+ config_file = config_file_path("wayland-desktop-shell.ini");
+ ret = parse_config_file(config_file, cs, ARRAY_LENGTH(cs), shell);
+ free(config_file);
+
+ return ret;
+ /* FIXME: free(shell->screensaver.path) on plugin fini */
+}
+
static void
move_grab_motion(struct wl_grab *grab,
uint32_t time, int32_t x, int32_t y)
@@ -503,9 +527,12 @@
if (shell->screensaver.binding)
return;
+ if (!shell->screensaver.path)
+ return;
+
wlsc_client_launch(shell->compositor,
&shell->screensaver.process,
- "./clients/wscreensaver",
+ shell->screensaver.path,
handle_screensaver_sigchld);
}
@@ -1214,6 +1241,9 @@
wl_list_init(&shell->panels);
wl_list_init(&shell->screensaver.surfaces);
+ if (shell_configuration(shell) < 0)
+ return -1;
+
if (wl_display_add_global(ec->wl_display, &wl_shell_interface,
shell, bind_shell) == NULL)
return -1;
diff --git a/wayland-desktop-shell.ini b/wayland-desktop-shell.ini
index 3a86935..d438a85 100644
--- a/wayland-desktop-shell.ini
+++ b/wayland-desktop-shell.ini
@@ -18,3 +18,7 @@
[launcher]
icon=/usr/share/icons/gnome/24x24/apps/arts.png
path=./clients/flower
+
+[screensaver]
+#path=./clients/wscreensaver
+