[gdm] Ignore session IDs ending with "-xorg" under X11



commit 0c9f6629bf2b25898375d020603efd3326f8824d
Author: Olivier Tilloy <olivier tilloy canonical com>
Date:   Tue Oct 17 18:15:12 2017 +0200

    Ignore session IDs ending with "-xorg" under X11
    
    This is done under the assumption that they are meant for Wayland only.
    It is expected that a session called "foo" would have a "foo.desktop" file
    under wayland-sessions/, a fallback "foo.desktop" under xsessions/, and
    another "foo-xorg.desktop" under xsessions (that may simply be a symlink
    to "foo.desktop") specifically for Wayland.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=788552

 libgdm/gdm-sessions.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)
---
diff --git a/libgdm/gdm-sessions.c b/libgdm/gdm-sessions.c
index 4a5434e..ee98135 100644
--- a/libgdm/gdm-sessions.c
+++ b/libgdm/gdm-sessions.c
@@ -157,6 +157,9 @@ collect_sessions_from_directory (const char *dirname)
         GDir       *dir;
         const char *filename;
 
+        gboolean is_x11 = g_getenv ("WAYLAND_DISPLAY") == NULL &&
+                          g_getenv ("RUNNING_UNDER_GDM") != NULL;
+
         /* FIXME: add file monitor to directory */
 
         dir = g_dir_open (dirname, 0, NULL);
@@ -171,6 +174,21 @@ collect_sessions_from_directory (const char *dirname)
                 if (! g_str_has_suffix (filename, ".desktop")) {
                         continue;
                 }
+
+                if (is_x11 && g_str_has_suffix (filename, "-xorg.desktop")) {
+                        char *base_name = g_strndup (filename, strlen (filename) - strlen ("-xorg.desktop"));
+                        char *fallback_name = g_strconcat (base_name, ".desktop", NULL);
+                        g_free (base_name);
+                        char *fallback_path = g_build_filename (dirname, fallback_name, NULL);
+                        g_free (fallback_name);
+                        if (g_file_test (fallback_path, G_FILE_TEST_EXISTS)) {
+                                g_free (fallback_path);
+                                g_debug ("Running under X11, ignoring %s", filename);
+                                continue;
+                        }
+                        g_free (fallback_path);
+                }
+
                 id = g_strndup (filename, strlen (filename) - strlen (".desktop"));
 
                 full_path = g_build_filename (dirname, filename, NULL);


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