[Xfce4-commits] [apps/xfce4-screensaver] 74/425: Add support to switch user with LightDM

noreply at xfce.org noreply at xfce.org
Mon Oct 15 01:48:41 CEST 2018


This is an automated email from the git hooks/post-receive script.

b   l   u   e   s   a   b   r   e       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository apps/xfce4-screensaver.

commit 523abce71252bed89941901233911497d4df415c
Author: Stefano Karapetsas <stefano at karapetsas.com>
Date:   Sat Apr 13 18:39:35 2013 +0200

    Add support to switch user with LightDM
---
 src/gs-lock-plug.c | 108 +++++++++++++++++++++++++++++++----------------------
 1 file changed, 63 insertions(+), 45 deletions(-)

diff --git a/src/gs-lock-plug.c b/src/gs-lock-plug.c
index 7f95adc..2f37e77 100644
--- a/src/gs-lock-plug.c
+++ b/src/gs-lock-plug.c
@@ -196,12 +196,9 @@ do_user_switch (GSLockPlug *plug)
 	gboolean res;
 	char    *command;
 
-	gboolean found;
-	found = is_program_in_path (MDM_FLEXISERVER_COMMAND);
-
-	if (found)
+	if (is_program_in_path (MDM_FLEXISERVER_COMMAND))
 	{
-
+		/* MDM */
 		command = g_strdup_printf ("%s %s",
 								   MDM_FLEXISERVER_COMMAND,
 								   MDM_FLEXISERVER_ARGS);
@@ -219,34 +216,56 @@ do_user_switch (GSLockPlug *plug)
 			g_error_free (error);
 		}
 	}
-	else {
-		
-		/* MDM not found, so we try to use gdmflexiserver from GDM */
-		
-		found = is_program_in_path (GDM_FLEXISERVER_COMMAND);
+	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 (),
+												command,
+												&error);
+
+		g_free (command);
 		
-		if (found)
-		{
-                
-			char    *gdm_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,
-											&error);
-
-			g_free (gdm_command);
-			
-			if (! res) {
-				gs_debug ("Unable to start MDM greeter: %s", error->message);
-				g_error_free (error);
-			}
+		if (! res) {
+			gs_debug ("Unable to start GDM greeter: %s", error->message);
+			g_error_free (error);
+		}
+	}
+	else if (g_getenv ("XDG_SEAT_PATH") != NULL)
+	{
+		/* LightDM */
+		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",
+											  g_getenv ("XDG_SEAT_PATH"),
+											  "org.freedesktop.DisplayManager.Seat",
+											  NULL,
+											  &error);
+		if (proxy != NULL) {
+			g_dbus_proxy_call_sync (proxy,
+									"SwitchToGreeter",
+									g_variant_new ("()"),
+									G_DBUS_CALL_FLAGS_NONE,
+									-1,
+									NULL,
+									NULL);
+			g_object_unref (proxy);
+		}
+		else {
+			gs_debug ("Unable to start LightDM greeter: %s", error->message);
+			g_error_free (error);
 		}
 	}
+
 }
 
 static void
@@ -1009,26 +1028,25 @@ gs_lock_plug_set_switch_enabled (GSLockPlug *plug,
 
 	if (switch_enabled)
 	{
-		gboolean found;
-		found = is_program_in_path (MDM_FLEXISERVER_COMMAND);
-		if (found)
+		if (is_program_in_path (MDM_FLEXISERVER_COMMAND))
 		{
+			/* MDM  */
+			gtk_widget_show (plug->priv->auth_switch_button);
+		}
+		else if (is_program_in_path (GDM_FLEXISERVER_COMMAND))
+		{
+			/* GDM */
+			gtk_widget_show (plug->priv->auth_switch_button);
+		}
+		else if (g_getenv ("XDG_SEAT_PATH") != NULL)
+		{
+			/* LightDM */
 			gtk_widget_show (plug->priv->auth_switch_button);
 		}
 		else
 		{
-			gs_debug ("Warning: MDM flexiserver command not found: %s", MDM_FLEXISERVER_COMMAND);
-			
-			/* MDM not found, so we try to use gdmflexiserver from GDM */
-			found = is_program_in_path (GDM_FLEXISERVER_COMMAND);
-			if (found)
-			{
-				gtk_widget_show (plug->priv->auth_switch_button);
-			}
-			else {
-				gs_debug ("Warning: GDM flexiserver command not found: %s", GDM_FLEXISERVER_COMMAND);
-				gtk_widget_hide (plug->priv->auth_switch_button);
-			}
+			gs_debug ("Warning: Unknown DM for switch button");
+			gtk_widget_hide (plug->priv->auth_switch_button);
 		}
 	}
 	else

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list