[gnome-settings-daemon/benzea/xsettings-clean-exit-no-x11] xsettings: Exit cleanly if X11 is not available




commit cc9a608be0cb1f687d3fded622f983d3ff184fce
Author: Benjamin Berg <bberg redhat com>
Date:   Thu Mar 11 19:19:10 2021 +0100

    xsettings: Exit cleanly if X11 is not available
    
    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.

 plugins/common/daemon-skeleton-gtk.h |  4 ++++
 plugins/xsettings/main.c             | 11 +++++++++++
 2 files changed, 15 insertions(+)
---
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"


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]