[Xfce4-commits] [apps/xfce4-screensaver] 174/425: check for running DM for user switching
noreply at xfce.org
noreply at xfce.org
Mon Oct 15 01:50:21 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 ef6a9ffce59463fcbdddf82b9838d0e14d5744a3
Author: raveit65 <chat-to-me at raveit.de>
Date: Wed Apr 1 22:00:34 2015 +0200
check for running DM for user switching
---
src/gs-lock-plug.c | 32 +++++++++++++++++---------------
1 file changed, 17 insertions(+), 15 deletions(-)
diff --git a/src/gs-lock-plug.c b/src/gs-lock-plug.c
index 91fac54..34aa87a 100644
--- a/src/gs-lock-plug.c
+++ b/src/gs-lock-plug.c
@@ -188,18 +188,20 @@ gs_lock_plug_style_set (GtkWidget *widget,
}
static gboolean
-is_program_in_path (const char *program)
+process_is_running (const char * name)
{
- char *tmp = g_find_program_in_path (program);
- if (tmp != NULL)
- {
- g_free (tmp);
- return TRUE;
- }
- else
- {
- return FALSE;
- }
+ int num_processes;
+ gchar *command = g_strdup_printf ("pidof %s | wc -l", name);
+ FILE *fp = popen(command, "r");
+ fscanf(fp, "%d", &num_processes);
+ pclose(fp);
+ g_free (command);
+
+ if (num_processes > 0) {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
}
static void
@@ -209,7 +211,7 @@ do_user_switch (GSLockPlug *plug)
gboolean res;
char *command;
- if (is_program_in_path (MDM_FLEXISERVER_COMMAND))
+ if (process_is_running ("mdm"))
{
/* MDM */
command = g_strdup_printf ("%s %s",
@@ -229,7 +231,7 @@ do_user_switch (GSLockPlug *plug)
g_error_free (error);
}
}
- else if (is_program_in_path (GDM_FLEXISERVER_COMMAND))
+ else if (process_is_running ("gdm") || process_is_running("gdm3"))
{
/* GDM */
command = g_strdup_printf ("%s %s",
@@ -1284,12 +1286,12 @@ gs_lock_plug_set_switch_enabled (GSLockPlug *plug,
if (switch_enabled)
{
- if (is_program_in_path (MDM_FLEXISERVER_COMMAND))
+ if (process_is_running ("mdm"))
{
/* MDM */
gtk_widget_show (plug->priv->auth_switch_button);
}
- else if (is_program_in_path (GDM_FLEXISERVER_COMMAND))
+ else if (process_is_running ("gdm") || process_is_running("gdm3"))
{
/* GDM */
gtk_widget_show (plug->priv->auth_switch_button);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list