summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Wimpress <[email protected]>2015-05-19 02:34:12 +0100
committerMartin Wimpress <[email protected]>2015-05-19 02:34:12 +0100
commit269333e2683e6dd9975f298267cac177b889541a (patch)
tree4f28771049bad50cc994a7129caf80e9e9c030de
parent70541859c5798d6c6cfb0853e8dc775b77a83319 (diff)
parentef6a9ffce59463fcbdddf82b9838d0e14d5744a3 (diff)
downloadmate-screensaver-269333e2683e6dd9975f298267cac177b889541a.tar.bz2
mate-screensaver-269333e2683e6dd9975f298267cac177b889541a.tar.xz
Merge pull request #70 from NiceandGently/master
check for running DM for user switching
-rw-r--r--src/gs-lock-plug.c32
1 files 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);