summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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