diff options
author | Martin Wimpress <[email protected]> | 2015-05-19 02:34:12 +0100 |
---|---|---|
committer | Martin Wimpress <[email protected]> | 2015-05-19 02:34:12 +0100 |
commit | 269333e2683e6dd9975f298267cac177b889541a (patch) | |
tree | 4f28771049bad50cc994a7129caf80e9e9c030de /src | |
parent | 70541859c5798d6c6cfb0853e8dc775b77a83319 (diff) | |
parent | ef6a9ffce59463fcbdddf82b9838d0e14d5744a3 (diff) | |
download | mate-screensaver-269333e2683e6dd9975f298267cac177b889541a.tar.bz2 mate-screensaver-269333e2683e6dd9975f298267cac177b889541a.tar.xz |
Merge pull request #70 from NiceandGently/master
check for running DM for user switching
Diffstat (limited to 'src')
-rw-r--r-- | src/gs-lock-plug.c | 32 |
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); |