Blob Blame History Raw
From 55fa78bacbb4537cdc2fb090cb2f607476cae780 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Tue, 7 Jan 2014 13:14:31 -0500
Subject: [PATCH] main: allow session mode to be specified in the environment

Specifying the session mode on the command-line doesn't play
well with session management (since the saved session desktop
file well either drop the specified session mode, or force it
always, even if the user picked a different mode at the login
screen)

This commit adds support for specifying the session mode via an
enviroment variable. For now, keep the old command line interface
for backward compatibility
---
 src/main.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/main.c b/src/main.c
index 9f7f890..1c42667 100644
--- a/src/main.c
+++ b/src/main.c
@@ -334,60 +334,62 @@ GOptionEntry gnome_shell_options[] = {
     N_("Mode used by GDM for login screen"),
     NULL
   },
   {
     "mode", 0, 0, G_OPTION_ARG_STRING,
     &session_mode,
     N_("Use a specific mode, e.g. \"gdm\" for login screen"),
     "MODE"
   },
   {
     "list-modes", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
     list_modes,
     N_("List possible modes"),
     NULL
   },
   { NULL }
 };
 
 int
 main (int argc, char **argv)
 {
   GOptionContext *ctx;
   GError *error = NULL;
   int ecode;
   TpDebugSender *sender;
 
   bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
   bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
   textdomain (GETTEXT_PACKAGE);
 
+  session_mode = (char *) g_getenv ("GNOME_SHELL_SESSION_MODE");
+
   ctx = meta_get_option_context ();
   g_option_context_add_main_entries (ctx, gnome_shell_options, GETTEXT_PACKAGE);
   if (!g_option_context_parse (ctx, &argc, &argv, &error))
     {
       g_printerr ("%s: %s\n", argv[0], error->message);
       exit (1);
     }
 
   g_option_context_free (ctx);
 
   meta_plugin_manager_set_plugin_type (gnome_shell_plugin_get_type ());
 
   meta_set_wm_name (WM_NAME);
   meta_set_gnome_wm_keybindings (GNOME_WM_KEYBINDINGS);
 
   /* Prevent meta_init() from causing gtk to load gail and at-bridge */
   g_setenv ("NO_AT_BRIDGE", "1", TRUE);
   meta_init ();
   g_unsetenv ("NO_AT_BRIDGE");
 
   /* FIXME: Add gjs API to set this stuff and don't depend on the
    * environment.  These propagate to child processes.
    */
   g_setenv ("GJS_DEBUG_OUTPUT", "stderr", TRUE);
   g_setenv ("GJS_DEBUG_TOPICS", "JS ERROR;JS LOG", TRUE);
 
   shell_dbus_init (meta_get_replace_current_wm ());
   shell_a11y_init ();
   shell_perf_log_init ();
   shell_introspection_init ();
-- 
1.8.3.1