summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Berg <bberg@redhat.com>2021-03-11 19:19:10 +0100
committerBenjamin Berg <bberg@redhat.com>2021-03-11 19:22:04 +0100
commitcc9a608be0cb1f687d3fded622f983d3ff184fce (patch)
tree16951912c6356a16723559ffb498e612cd3b7c1a
parent5ef6f83b63500da3e8249920bca07445aa7297cc (diff)
downloadgnome-settings-daemon-benzea/xsettings-clean-exit-no-x11.tar.gz
xsettings: Exit cleanly if X11 is not availablebenzea/xsettings-clean-exit-no-x11
This could happen in a non-systemd started wayland session that has no Xwayland support. In this case, just exiting cleanly means that gnome-session should consider the service as being "successful" rather than considering it a failure of a required component.
-rw-r--r--plugins/common/daemon-skeleton-gtk.h4
-rw-r--r--plugins/xsettings/main.c11
2 files changed, 15 insertions, 0 deletions
diff --git a/plugins/common/daemon-skeleton-gtk.h b/plugins/common/daemon-skeleton-gtk.h
index 596281df..ed5b4b6b 100644
--- a/plugins/common/daemon-skeleton-gtk.h
+++ b/plugins/common/daemon-skeleton-gtk.h
@@ -231,6 +231,10 @@ main (int argc, char **argv)
gdk_set_allowed_backends (GDK_BACKEND);
#endif
+#ifdef MAIN_HOOK
+ MAIN_HOOK ();
+#endif
+
error = NULL;
if (! gtk_init_with_args (&argc, &argv, PLUGIN_NAME, entries, NULL, &error)) {
if (error != NULL) {
diff --git a/plugins/xsettings/main.c b/plugins/xsettings/main.c
index 65d9a203..bc15132a 100644
--- a/plugins/xsettings/main.c
+++ b/plugins/xsettings/main.c
@@ -3,6 +3,17 @@
#define STOP gsd_xsettings_manager_stop
#define MANAGER GsdXSettingsManager
#define GDK_BACKEND "x11"
+#define MAIN_HOOK main_hook
+
+#include <glib.h>
+
+static void main_hook (void)
+{
+ /* Do not try to run if X11 is not available */
+ if (g_getenv ("DISPLAY") == NULL)
+ exit (0);
+}
+
#include "gsd-xsettings-manager.h"
#include "daemon-skeleton-gtk.h"