summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mate-session/gsm-inhibit-dialog.c23
-rw-r--r--mate-session/gsm-manager.c36
-rw-r--r--mate-session/gsm-util.c27
-rw-r--r--mate-session/gsm-util.h2
4 files changed, 70 insertions, 18 deletions
diff --git a/mate-session/gsm-inhibit-dialog.c b/mate-session/gsm-inhibit-dialog.c
index a4e86e8..c79fa18 100644
--- a/mate-session/gsm-inhibit-dialog.c
+++ b/mate-session/gsm-inhibit-dialog.c
@@ -91,13 +91,24 @@ G_DEFINE_TYPE (GsmInhibitDialog, gsm_inhibit_dialog, GTK_TYPE_DIALOG)
static void
lock_screen (GsmInhibitDialog *dialog)
{
- GError *error;
- error = NULL;
- g_spawn_command_line_async ("mate-screensaver-command --lock", &error);
- if (error != NULL) {
- g_warning ("Couldn't lock screen: %s", error->message);
- g_error_free (error);
+ gchar **screen_locker_command;
+
+ if ((screen_locker_command = gsm_get_screen_locker_command ()) != NULL) {
+ GError *error = NULL;
+
+ g_spawn_async (NULL, screen_locker_command, NULL, G_SPAWN_DEFAULT,
+ NULL, NULL, NULL, &error);
+
+ if (error != NULL) {
+ g_warning ("Couldn't lock screen: %s", error->message);
+ g_error_free (error);
+ }
+
+ } else {
+ g_warning ("Couldn't find any screen locker");
}
+
+ g_strfreev (screen_locker_command);
}
static void
diff --git a/mate-session/gsm-manager.c b/mate-session/gsm-manager.c
index 817688a..4be8eb0 100644
--- a/mate-session/gsm-manager.c
+++ b/mate-session/gsm-manager.c
@@ -1224,21 +1224,33 @@ sleep_lock_is_enabled (GsmManager *manager)
static void
manager_perhaps_lock (GsmManager *manager)
{
- GError *error;
- gboolean ret;
+ gchar **screen_locker_command;
- /* only lock if mate-screensaver is set to lock */
- if (!sleep_lock_is_enabled (manager)) {
- return;
- }
+ if ((screen_locker_command = gsm_get_screen_locker_command ()) != NULL) {
+ GError *error = NULL;
- /* do this sync to ensure it's on the screen when we start suspending */
- error = NULL;
- ret = g_spawn_command_line_sync ("mate-screensaver-command --lock", NULL, NULL, NULL, &error);
- if (!ret) {
- g_warning ("Couldn't lock screen: %s", error->message);
- g_error_free (error);
+ /* only lock if mate-screensaver is set to lock */
+ if (!g_strcmp0 (screen_locker_command[0], "mate-screensaver-command") &&
+ !sleep_lock_is_enabled (manager)) {
+ goto clear_screen_locker_command;
+ }
+
+ /* do this sync to ensure it's on the screen when we start suspending */
+ g_spawn_sync (NULL, screen_locker_command, NULL, G_SPAWN_DEFAULT,
+ NULL, NULL, NULL, NULL, NULL, &error);
+
+ if (error) {
+ g_warning ("Couldn't lock screen: %s", error->message);
+ g_error_free (error);
+ }
+
+ } else {
+ g_warning ("Couldn't find any screen locker");
}
+
+clear_screen_locker_command:
+
+ g_strfreev (screen_locker_command);
}
static void
diff --git a/mate-session/gsm-util.c b/mate-session/gsm-util.c
index a769d8c..76bf9cd 100644
--- a/mate-session/gsm-util.c
+++ b/mate-session/gsm-util.c
@@ -38,6 +38,33 @@
static gchar *_saved_session_dir = NULL;
+gchar **
+gsm_get_screen_locker_command (void)
+{
+ const char *screen_locker_command[] = {
+ "mate-screensaver-command --lock",
+ "xscreensaver-command -lock",
+ NULL
+ };
+ gchar **screen_locker_argv = NULL;
+ gsize i;
+
+ for (i = 0; screen_locker_command[i] != NULL && screen_locker_argv == NULL; i++) {
+ gchar **argv;
+ char *path;
+
+ argv = g_strsplit (screen_locker_command [i], " ", -1);
+ path = g_find_program_in_path (argv[0]);
+ if (path)
+ screen_locker_argv = g_strdupv (argv);
+
+ g_free (path);
+ g_strfreev (argv);
+ }
+
+ return screen_locker_argv;
+}
+
char *
gsm_util_find_desktop_file_for_app_name (const char *name,
char **autostart_dirs)
diff --git a/mate-session/gsm-util.h b/mate-session/gsm-util.h
index dcec60e..d1c3c5c 100644
--- a/mate-session/gsm-util.h
+++ b/mate-session/gsm-util.h
@@ -29,6 +29,8 @@ extern "C" {
#define IS_STRING_EMPTY(x) ((x)==NULL||(x)[0]=='\0')
+gchar** gsm_get_screen_locker_command (void);
+
char * gsm_util_find_desktop_file_for_app_name (const char *app_name,
char **dirs);