diff options
author | raveit65 <[email protected]> | 2015-04-01 22:00:34 +0200 |
---|---|---|
committer | raveit65 <[email protected]> | 2015-04-01 22:00:34 +0200 |
commit | ef6a9ffce59463fcbdddf82b9838d0e14d5744a3 (patch) | |
tree | 72d132bf9a81e276973b39d569d79ae80068a530 /src/gs-lock-plug.c | |
parent | a6e588cec63f2559b06304ec0859210d7b9de859 (diff) | |
download | mate-screensaver-ef6a9ffce59463fcbdddf82b9838d0e14d5744a3.tar.bz2 mate-screensaver-ef6a9ffce59463fcbdddf82b9838d0e14d5744a3.tar.xz |
check for running DM for user switching
Diffstat (limited to 'src/gs-lock-plug.c')
-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); |