Blame SOURCES/classic-session.patch

1e501a
From be12e2373f73c900de9eedde4ce2c85821bfdd3f Mon Sep 17 00:00:00 2001
f3033d
From: Ray Strode <rstrode@redhat.com>
f3033d
Date: Wed, 3 Apr 2013 10:28:09 -0400
1e501a
Subject: [PATCH] session: change default session
f3033d
1e501a
We default to gnome-classic in rhel, unless overridden
1e501a
by /etc/sysconfig/desktop
f3033d
---
1e501a
 daemon/gdm-session.c | 100 +++++++++++++++++++++++++++++++++++++++++++++++++++
1e501a
 1 file changed, 100 insertions(+)
f3033d
f3033d
diff --git a/daemon/gdm-session.c b/daemon/gdm-session.c
1e501a
index 4cc0879..b89364d 100644
f3033d
--- a/daemon/gdm-session.c
f3033d
+++ b/daemon/gdm-session.c
1e501a
@@ -540,9 +540,89 @@ get_default_language_name (GdmSession *self)
f3033d
 }
1e501a
 
f3033d
 static const char *
1e501a
+get_configured_default_session_name (GdmSession *self)
1e501a
+{
1e501a
+        static const char *config_file = "/etc/sysconfig/desktop";
1e501a
+        const char    *session_name = "gnome-classic";
1e501a
+        gchar         *contents = NULL;
1e501a
+        gchar         *p;
1e501a
+        gsize          length;
1e501a
+        GError        *error;
1e501a
+        GString       *line;
1e501a
+        GRegex        *re;
1e501a
+
1e501a
+        if (!g_file_test (config_file, G_FILE_TEST_EXISTS)) {
1e501a
+                g_debug ("Cannot access '%s'", config_file);
1e501a
+                return session_name;
1e501a
+        }
1e501a
+
1e501a
+        error = NULL;
1e501a
+        if (!g_file_get_contents (config_file, &contents, &length, &error)) {
1e501a
+                g_debug ("Failed to parse '%s': %s",
1e501a
+                         config_file,
1e501a
+                         (error && error->message) ? error->message : "(null)");
1e501a
+                g_error_free (error);
1e501a
+                return session_name;
1e501a
+        }
1e501a
+
1e501a
+        if (!g_utf8_validate (contents, length, NULL)) {
1e501a
+                g_warning ("Invalid UTF-8 in '%s'", config_file);
1e501a
+                g_free (contents);
1e501a
+                return session_name;
1e501a
+        }
1e501a
+
1e501a
+        re = g_regex_new ("DESKTOP=\"?KDE\"?[ \t]*", 0, 0, &error);
1e501a
+        if (re == NULL) {
1e501a
+                g_warning ("Failed to regex: %s",
1e501a
+                           (error && error->message) ? error->message : "(null)");
1e501a
+                g_error_free (error);
1e501a
+                g_free (contents);
1e501a
+                return session_name;
1e501a
+        }
1e501a
+
1e501a
+        line = g_string_new ("");
1e501a
+        for (p = contents; p && *p; p = g_utf8_find_next_char (p, NULL)) {
1e501a
+                gunichar ch;
1e501a
+                GMatchInfo *match_info = NULL;
1e501a
+
1e501a
+                ch = g_utf8_get_char (p);
1e501a
+                if ((ch != '\n') && (ch != '\0')) {
1e501a
+                        g_string_append_unichar (line, ch);
1e501a
+                        continue;
1e501a
+                }
1e501a
+
1e501a
+                if (line->str && g_utf8_get_char (line->str) == '#') {
1e501a
+                        goto next_line;
1e501a
+                }
1e501a
+
1e501a
+                if (!g_regex_match (re, line->str, 0, &match_info)) {
1e501a
+                        goto next_line;
1e501a
+                }
1e501a
+
1e501a
+                if (!g_match_info_matches (match_info)) {
1e501a
+                        goto next_line;
1e501a
+                }
1e501a
+
1e501a
+                session_name = "1-kde-plasma-standard";
1e501a
+                break;
1e501a
+
1e501a
+next_line:
1e501a
+                g_match_info_free (match_info);
1e501a
+                g_string_set_size (line, 0);
1e501a
+        }
1e501a
+
1e501a
+        g_string_free (line, TRUE);
1e501a
+        g_regex_unref (re);
1e501a
+        g_free (contents);
1e501a
+
1e501a
+        return session_name;
1e501a
+}
1e501a
+
1e501a
+static const char *
f3033d
 get_fallback_session_name (GdmSession *self)
f3033d
 {
f3033d
         const char    **search_dirs;
1e501a
+        const char     *configured_session;
f3033d
         int             i;
f3033d
         char           *name;
f3033d
         GSequence      *sessions;
1e501a
@@ -555,6 +635,26 @@ get_fallback_session_name (GdmSession *self)
f3033d
                 }
f3033d
         }
1e501a
 
1e501a
+        configured_session = get_configured_default_session_name (self);
1e501a
+
1e501a
+        name = g_strdup (configured_session);
f3033d
+        if (get_session_command_for_name (name, NULL)) {
f3033d
+                g_free (self->priv->fallback_session_name);
f3033d
+                self->priv->fallback_session_name = name;
f3033d
+                goto out;
f3033d
+        }
f3033d
+        g_free (name);
f3033d
+
1e501a
+        if (g_strcmp0 (configured_session, "gnome-classic") != 0) {
1e501a
+                name = g_strdup ("gnome-classic");
1e501a
+                if (get_session_command_for_name (name, NULL)) {
1e501a
+                        g_free (self->priv->fallback_session_name);
1e501a
+                        self->priv->fallback_session_name = name;
1e501a
+                        goto out;
1e501a
+                }
1e501a
+                g_free (name);
1e501a
+        }
1e501a
+
f3033d
         name = g_strdup ("gnome");
f3033d
         if (get_session_command_for_name (name, NULL)) {
f3033d
                 g_free (self->priv->fallback_session_name);
1e501a
-- 
1e501a
2.3.7
f3033d