summaryrefslogtreecommitdiff
path: root/mate-session/gsm-manager.c
diff options
context:
space:
mode:
authorStefano Karapetsas <[email protected]>2013-04-13 14:04:34 +0200
committerStefano Karapetsas <[email protected]>2013-04-13 14:04:34 +0200
commitaca91616f1c9845d860768f0f4d321cfdc515c62 (patch)
treea8d9e662065b33949c828662b2d6c6dd282dbda4 /mate-session/gsm-manager.c
parent416d2ccbd5158dc4b49e89a9c88c96382b29c5eb (diff)
downloadmate-session-manager-aca91616f1c9845d860768f0f4d321cfdc515c62.tar.bz2
mate-session-manager-aca91616f1c9845d860768f0f4d321cfdc515c62.tar.xz
Add support to switch user with LightDM
http://bazaar.launchpad.net/~lightdm-team/lightdm/trunk/view/head:/utils/gdmflexiserver Closes #22 (https://github.com/mate-desktop/mate-session-manager/issues/22)
Diffstat (limited to 'mate-session/gsm-manager.c')
-rw-r--r--mate-session/gsm-manager.c86
1 files changed, 67 insertions, 19 deletions
diff --git a/mate-session/gsm-manager.c b/mate-session/gsm-manager.c
index de29f8f..02758f5 100644
--- a/mate-session/gsm-manager.c
+++ b/mate-session/gsm-manager.c
@@ -973,6 +973,20 @@ cancel_end_session (GsmManager *manager)
start_phase (manager);
}
+static gboolean
+is_program_in_path (const char *program)
+{
+ char *tmp = g_find_program_in_path (program);
+ if (tmp != NULL)
+ {
+ g_free (tmp);
+ return TRUE;
+ }
+ else
+ {
+ return FALSE;
+ }
+}
static void
manager_switch_user (GsmManager *manager)
@@ -981,41 +995,75 @@ manager_switch_user (GsmManager *manager)
gboolean res;
char *command;
- command = g_strdup_printf ("%s %s",
- MDM_FLEXISERVER_COMMAND,
- MDM_FLEXISERVER_ARGS);
+ if (is_program_in_path (MDM_FLEXISERVER_COMMAND)) {
+ /* MDM */
+ command = g_strdup_printf ("%s %s",
+ MDM_FLEXISERVER_COMMAND,
+ MDM_FLEXISERVER_ARGS);
- error = NULL;
- res = gdk_spawn_command_line_on_screen (gdk_screen_get_default (),
- command,
- &error);
+ error = NULL;
+ res = gdk_spawn_command_line_on_screen (gdk_screen_get_default (),
+ command,
+ &error);
- g_free (command);
+ g_free (command);
- if (! res) {
- g_debug ("GsmManager: Unable to start MDM greeter: %s", error->message);
- g_error_free (error);
-
- /* MDM not found, so we try to use gdmflexiserver from GDM */
-
- char *gdm_command;
-
- gdm_command = g_strdup_printf ("%s %s",
+ if (! res) {
+ g_debug ("GsmManager: Unable to start MDM greeter: %s", error->message);
+ g_error_free (error);
+ }
+ }
+ else if (is_program_in_path (GDM_FLEXISERVER_COMMAND)) {
+ /* GDM */
+ command = g_strdup_printf ("%s %s",
GDM_FLEXISERVER_COMMAND,
GDM_FLEXISERVER_ARGS);
error = NULL;
res = gdk_spawn_command_line_on_screen (gdk_screen_get_default (),
- gdm_command,
+ command,
&error);
- g_free (gdm_command);
+ g_free (command);
if (! res) {
g_debug ("GsmManager: Unable to start GDM greeter: %s", error->message);
g_error_free (error);
}
}
+ else {
+ /* LightDM */
+ const gchar *xdg_seat_path = g_getenv ("XDG_SEAT_PATH");
+ if (xdg_seat_path != NULL) {
+ GDBusProxyFlags flags = G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START;
+ GDBusProxy *proxy = NULL;
+ error = NULL;
+
+ proxy = g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM,
+ flags,
+ NULL,
+ "org.freedesktop.DisplayManager",
+ xdg_seat_path,
+ "org.freedesktop.DisplayManager.Seat",
+ NULL,
+ &error);
+ if (proxy != NULL) {
+ g_dbus_proxy_call (proxy,
+ "SwitchToGreeter",
+ g_variant_new ("()"),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ NULL,
+ NULL);
+ g_object_unref (proxy);
+ }
+ else {
+ g_debug ("GsmManager: Unable to start LightDM greeter: %s", error->message);
+ g_error_free (error);
+ }
+ }
+ }
}
static gboolean