|
|
f42647 |
From 45848cf2625eaec34a07c03fdee624c8a2cb76de Mon Sep 17 00:00:00 2001
|
|
|
2fc437 |
From: Ray Strode <rstrode@redhat.com>
|
|
|
2fc437 |
Date: Wed, 3 Apr 2013 10:28:09 -0400
|
|
|
f42647 |
Subject: [PATCH 8/8] session: change default session
|
|
|
2fc437 |
|
|
|
2fc437 |
We default to gnome-classic in rhel, unless overridden
|
|
|
2fc437 |
by /etc/sysconfig/desktop
|
|
|
2fc437 |
---
|
|
|
2fc437 |
daemon/gdm-session.c | 100 +++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
2fc437 |
1 file changed, 100 insertions(+)
|
|
|
2fc437 |
|
|
|
2fc437 |
diff --git a/daemon/gdm-session.c b/daemon/gdm-session.c
|
|
|
f42647 |
index f62f77d0..d6f1e121 100644
|
|
|
2fc437 |
--- a/daemon/gdm-session.c
|
|
|
2fc437 |
+++ b/daemon/gdm-session.c
|
|
|
f42647 |
@@ -495,76 +495,176 @@ get_session_command_for_name (GdmSession *self,
|
|
|
f42647 |
{
|
|
|
2fc437 |
gboolean res;
|
|
|
2fc437 |
char *filename;
|
|
|
2fc437 |
|
|
|
2fc437 |
filename = g_strdup_printf ("%s.desktop", name);
|
|
|
2fc437 |
res = get_session_command_for_file (self, filename, command);
|
|
|
2fc437 |
g_free (filename);
|
|
|
2fc437 |
|
|
|
2fc437 |
return res;
|
|
|
2fc437 |
}
|
|
|
2fc437 |
|
|
|
2fc437 |
static const char *
|
|
|
2fc437 |
get_default_language_name (GdmSession *self)
|
|
|
2fc437 |
{
|
|
|
2fc437 |
const char *default_language;
|
|
|
2fc437 |
|
|
|
2fc437 |
if (self->priv->saved_language != NULL) {
|
|
|
2fc437 |
return self->priv->saved_language;
|
|
|
2fc437 |
}
|
|
|
2fc437 |
|
|
|
2fc437 |
default_language = g_hash_table_lookup (self->priv->environment,
|
|
|
2fc437 |
"LANG");
|
|
|
2fc437 |
|
|
|
2fc437 |
if (default_language != NULL) {
|
|
|
2fc437 |
return default_language;
|
|
|
2fc437 |
}
|
|
|
2fc437 |
|
|
|
2fc437 |
return setlocale (LC_MESSAGES, NULL);
|
|
|
2fc437 |
}
|
|
|
2fc437 |
|
|
|
f42647 |
+static const char *
|
|
|
2fc437 |
+get_configured_default_session_name (GdmSession *self)
|
|
|
2fc437 |
+{
|
|
|
2fc437 |
+ static const char *config_file = "/etc/sysconfig/desktop";
|
|
|
2fc437 |
+ const char *session_name = "gnome-classic";
|
|
|
2fc437 |
+ gchar *contents = NULL;
|
|
|
2fc437 |
+ gchar *p;
|
|
|
2fc437 |
+ gsize length;
|
|
|
2fc437 |
+ GError *error;
|
|
|
2fc437 |
+ GString *line;
|
|
|
2fc437 |
+ GRegex *re;
|
|
|
2fc437 |
+
|
|
|
2fc437 |
+ if (!g_file_test (config_file, G_FILE_TEST_EXISTS)) {
|
|
|
2fc437 |
+ g_debug ("Cannot access '%s'", config_file);
|
|
|
2fc437 |
+ return session_name;
|
|
|
2fc437 |
+ }
|
|
|
2fc437 |
+
|
|
|
2fc437 |
+ error = NULL;
|
|
|
2fc437 |
+ if (!g_file_get_contents (config_file, &contents, &length, &error)) {
|
|
|
2fc437 |
+ g_debug ("Failed to parse '%s': %s",
|
|
|
2fc437 |
+ config_file,
|
|
|
2fc437 |
+ (error && error->message) ? error->message : "(null)");
|
|
|
2fc437 |
+ g_error_free (error);
|
|
|
2fc437 |
+ return session_name;
|
|
|
2fc437 |
+ }
|
|
|
2fc437 |
+
|
|
|
2fc437 |
+ if (!g_utf8_validate (contents, length, NULL)) {
|
|
|
2fc437 |
+ g_warning ("Invalid UTF-8 in '%s'", config_file);
|
|
|
2fc437 |
+ g_free (contents);
|
|
|
2fc437 |
+ return session_name;
|
|
|
2fc437 |
+ }
|
|
|
2fc437 |
+
|
|
|
2fc437 |
+ re = g_regex_new ("DESKTOP=\"?KDE\"?[ \t]*", 0, 0, &error);
|
|
|
2fc437 |
+ if (re == NULL) {
|
|
|
2fc437 |
+ g_warning ("Failed to regex: %s",
|
|
|
2fc437 |
+ (error && error->message) ? error->message : "(null)");
|
|
|
2fc437 |
+ g_error_free (error);
|
|
|
2fc437 |
+ g_free (contents);
|
|
|
2fc437 |
+ return session_name;
|
|
|
2fc437 |
+ }
|
|
|
2fc437 |
+
|
|
|
2fc437 |
+ line = g_string_new ("");
|
|
|
2fc437 |
+ for (p = contents; p && *p; p = g_utf8_find_next_char (p, NULL)) {
|
|
|
2fc437 |
+ gunichar ch;
|
|
|
2fc437 |
+ GMatchInfo *match_info = NULL;
|
|
|
2fc437 |
+
|
|
|
2fc437 |
+ ch = g_utf8_get_char (p);
|
|
|
2fc437 |
+ if ((ch != '\n') && (ch != '\0')) {
|
|
|
2fc437 |
+ g_string_append_unichar (line, ch);
|
|
|
2fc437 |
+ continue;
|
|
|
2fc437 |
+ }
|
|
|
2fc437 |
+
|
|
|
2fc437 |
+ if (line->str && g_utf8_get_char (line->str) == '#') {
|
|
|
2fc437 |
+ goto next_line;
|
|
|
2fc437 |
+ }
|
|
|
2fc437 |
+
|
|
|
2fc437 |
+ if (!g_regex_match (re, line->str, 0, &match_info)) {
|
|
|
2fc437 |
+ goto next_line;
|
|
|
2fc437 |
+ }
|
|
|
2fc437 |
+
|
|
|
2fc437 |
+ if (!g_match_info_matches (match_info)) {
|
|
|
2fc437 |
+ goto next_line;
|
|
|
2fc437 |
+ }
|
|
|
2fc437 |
+
|
|
|
2fc437 |
+ session_name = "1-kde-plasma-standard";
|
|
|
2fc437 |
+ break;
|
|
|
2fc437 |
+
|
|
|
2fc437 |
+next_line:
|
|
|
2fc437 |
+ g_match_info_free (match_info);
|
|
|
2fc437 |
+ g_string_set_size (line, 0);
|
|
|
2fc437 |
+ }
|
|
|
2fc437 |
+
|
|
|
2fc437 |
+ g_string_free (line, TRUE);
|
|
|
2fc437 |
+ g_regex_unref (re);
|
|
|
2fc437 |
+ g_free (contents);
|
|
|
2fc437 |
+
|
|
|
2fc437 |
+ return session_name;
|
|
|
2fc437 |
+}
|
|
|
2fc437 |
+
|
|
|
f42647 |
static const char *
|
|
|
2fc437 |
get_fallback_session_name (GdmSession *self)
|
|
|
2fc437 |
{
|
|
|
f42647 |
char **search_dirs;
|
|
|
2fc437 |
+ const char *configured_session;
|
|
|
2fc437 |
int i;
|
|
|
2fc437 |
char *name;
|
|
|
2fc437 |
GSequence *sessions;
|
|
|
2fc437 |
GSequenceIter *session;
|
|
|
2fc437 |
|
|
|
2fc437 |
if (self->priv->fallback_session_name != NULL) {
|
|
|
2fc437 |
/* verify that the cached version still exists */
|
|
|
2fc437 |
if (get_session_command_for_name (self, self->priv->fallback_session_name, NULL)) {
|
|
|
2fc437 |
goto out;
|
|
|
2fc437 |
}
|
|
|
2fc437 |
}
|
|
|
2fc437 |
|
|
|
2fc437 |
+ configured_session = get_configured_default_session_name (self);
|
|
|
2fc437 |
+
|
|
|
2fc437 |
+ name = g_strdup (configured_session);
|
|
|
2fc437 |
+ if (get_session_command_for_name (self, name, NULL)) {
|
|
|
2fc437 |
+ g_free (self->priv->fallback_session_name);
|
|
|
2fc437 |
+ self->priv->fallback_session_name = name;
|
|
|
2fc437 |
+ goto out;
|
|
|
2fc437 |
+ }
|
|
|
2fc437 |
+ g_free (name);
|
|
|
2fc437 |
+
|
|
|
2fc437 |
+ if (g_strcmp0 (configured_session, "gnome-classic") != 0) {
|
|
|
2fc437 |
+ name = g_strdup ("gnome-classic");
|
|
|
2fc437 |
+ if (get_session_command_for_name (self, name, NULL)) {
|
|
|
2fc437 |
+ g_free (self->priv->fallback_session_name);
|
|
|
2fc437 |
+ self->priv->fallback_session_name = name;
|
|
|
2fc437 |
+ goto out;
|
|
|
2fc437 |
+ }
|
|
|
2fc437 |
+ g_free (name);
|
|
|
2fc437 |
+ }
|
|
|
2fc437 |
+
|
|
|
2fc437 |
name = g_strdup ("gnome");
|
|
|
2fc437 |
if (get_session_command_for_name (self, name, NULL)) {
|
|
|
2fc437 |
g_free (self->priv->fallback_session_name);
|
|
|
2fc437 |
self->priv->fallback_session_name = name;
|
|
|
2fc437 |
goto out;
|
|
|
2fc437 |
}
|
|
|
2fc437 |
g_free (name);
|
|
|
2fc437 |
|
|
|
2fc437 |
sessions = g_sequence_new (g_free);
|
|
|
2fc437 |
|
|
|
2fc437 |
search_dirs = get_system_session_dirs (self);
|
|
|
2fc437 |
for (i = 0; search_dirs[i] != NULL; i++) {
|
|
|
2fc437 |
GDir *dir;
|
|
|
2fc437 |
const char *base_name;
|
|
|
2fc437 |
|
|
|
2fc437 |
dir = g_dir_open (search_dirs[i], 0, NULL);
|
|
|
2fc437 |
|
|
|
2fc437 |
if (dir == NULL) {
|
|
|
2fc437 |
continue;
|
|
|
2fc437 |
}
|
|
|
2fc437 |
|
|
|
2fc437 |
do {
|
|
|
2fc437 |
base_name = g_dir_read_name (dir);
|
|
|
2fc437 |
|
|
|
2fc437 |
if (base_name == NULL) {
|
|
|
2fc437 |
break;
|
|
|
2fc437 |
}
|
|
|
2fc437 |
|
|
|
2fc437 |
if (!g_str_has_suffix (base_name, ".desktop")) {
|
|
|
2fc437 |
continue;
|
|
|
2fc437 |
--
|
|
|
f42647 |
2.14.2
|
|
|
2fc437 |
|