2010-12-04 20:07:37 +01:00
|
|
|
diff --git a/Makefile.am b/Makefile.am
|
|
|
|
index 6e86875..5e53b41 100644
|
|
|
|
--- a/Makefile.am
|
|
|
|
+++ b/Makefile.am
|
|
|
|
@@ -11,7 +11,11 @@ image_DATA= \
|
|
|
|
images/gnome-session-suspend.png \
|
|
|
|
images/gnome-session-switch.png
|
|
|
|
|
|
|
|
+scripts= lxlock
|
|
|
|
+bin_SCRIPTS= $(scripts)
|
|
|
|
+
|
|
|
|
EXTRA_DIST = \
|
|
|
|
desktop.conf.example \
|
|
|
|
- $(image_DATA)
|
|
|
|
+ $(scripts) \
|
|
|
|
+ $(image_DATA) \
|
|
|
|
$(NULL)
|
|
|
|
diff --git a/lxlock b/lxlock
|
|
|
|
new file mode 100644
|
|
|
|
index 0000000..447aa9a
|
|
|
|
--- /dev/null
|
|
|
|
+++ b/lxlock
|
|
|
|
@@ -0,0 +1,40 @@
|
|
|
|
+#!/bin/sh
|
|
|
|
+#
|
|
|
|
+# lxlock - try to lock the screen
|
|
|
|
+#
|
|
|
|
+# Copyright (c) 2010 Guido Berhoerster <gber@opensuse.org>
|
|
|
|
+#
|
|
|
|
+# Permission to use, copy, modify, and distribute this software for any
|
|
|
|
+# purpose with or without fee is hereby granted, provided that the above
|
|
|
|
+# copyright notice and this permission notice appear in all copies.
|
|
|
|
+#
|
|
|
|
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
+# TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
+# PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
+
|
|
|
|
+PATH=/bin:/usr/bin
|
|
|
|
+export PATH
|
|
|
|
+
|
|
|
|
+for lock_cmd in \
|
|
|
|
+ "xscreensaver-command -lock" \
|
|
|
|
+ "gnome-screensaver-command --lock"
|
|
|
|
+do
|
|
|
|
+ $lock_cmd >/dev/null 2>&1 && exit
|
|
|
|
+done
|
|
|
|
+
|
|
|
|
+for lock_cmd in \
|
|
|
|
+ "slock" \
|
|
|
|
+ "xlock -mode blank"
|
|
|
|
+do
|
|
|
|
+ set -- $lock_cmd
|
|
|
|
+ if command -v -- $1 >/dev/null 2>&1; then
|
|
|
|
+ $lock_cmd >/dev/null 2>&1 &
|
|
|
|
+ exit
|
|
|
|
+ fi
|
|
|
|
+done
|
|
|
|
+
|
|
|
|
+exit 1
|
|
|
|
diff --git a/lxsession-logout/lxsession-logout.c b/lxsession-logout/lxsession-logout.c
|
|
|
|
index 435216c..6c6f89c 100644
|
|
|
|
--- a/lxsession-logout/lxsession-logout.c
|
|
|
|
+++ b/lxsession-logout/lxsession-logout.c
|
2010-07-14 10:44:57 +02:00
|
|
|
@@ -25,6 +25,7 @@
|
|
|
|
#include <glib/gi18n.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
+#include <sys/wait.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <limits.h>
|
|
|
|
#include <signal.h>
|
2010-12-04 20:07:37 +01:00
|
|
|
@@ -73,6 +74,7 @@ typedef struct {
|
2010-11-16 19:36:11 +01:00
|
|
|
int ltsp : 1; /* Shutdown and reboot is accomplished via LTSP */
|
2010-07-14 10:44:57 +02:00
|
|
|
} HandlerContext;
|
|
|
|
|
|
|
|
+static gboolean lock_screen(void);
|
|
|
|
static gboolean verify_running(char * display_manager, char * executable);
|
|
|
|
static void logout_clicked(GtkButton * button, HandlerContext * handler_context);
|
2010-11-16 19:36:11 +01:00
|
|
|
static void change_root_property(GtkWidget* w, const char* prop_name, const char* value);
|
2010-12-04 20:07:37 +01:00
|
|
|
@@ -85,6 +87,18 @@ static void cancel_clicked(GtkButton * button, gpointer user_data);
|
2010-07-14 10:44:57 +02:00
|
|
|
static GtkPositionType get_banner_position(void);
|
|
|
|
static GdkPixbuf * get_background_pixbuf(void);
|
|
|
|
|
2010-12-04 20:07:37 +01:00
|
|
|
+/* Try to run lxlock command in order to lock the screen, return TRUE on
|
|
|
|
+ * success, FALSE if command execution failed
|
2010-07-14 10:44:57 +02:00
|
|
|
+ */
|
|
|
|
+static gboolean lock_screen(void)
|
|
|
|
+{
|
2010-12-04 20:07:37 +01:00
|
|
|
+ if (!g_spawn_command_line_async("lxlock", NULL))
|
2010-07-14 10:44:57 +02:00
|
|
|
+ {
|
2010-12-04 20:07:37 +01:00
|
|
|
+ return TRUE;
|
2010-07-17 13:04:41 +02:00
|
|
|
+ }
|
2010-07-14 10:44:57 +02:00
|
|
|
+ return FALSE;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
/* Verify that a program is running and that an executable is available. */
|
|
|
|
static gboolean verify_running(char * display_manager, char * executable)
|
|
|
|
{
|
2010-12-04 20:07:37 +01:00
|
|
|
@@ -205,6 +219,7 @@ static void suspend_clicked(GtkButton * button, HandlerContext * handler_context
|
2010-11-16 19:36:11 +01:00
|
|
|
char * error_result = NULL;
|
|
|
|
gtk_label_set_text(GTK_LABEL(handler_context->error_label), NULL);
|
|
|
|
|
2010-07-14 10:44:57 +02:00
|
|
|
+ lock_screen();
|
2010-11-16 19:36:11 +01:00
|
|
|
if (handler_context->suspend_UPower)
|
|
|
|
error_result = dbus_UPower_Suspend();
|
2010-07-14 10:44:57 +02:00
|
|
|
else if (handler_context->suspend_HAL)
|
2010-12-04 20:07:37 +01:00
|
|
|
@@ -221,6 +236,7 @@ static void hibernate_clicked(GtkButton * button, HandlerContext * handler_conte
|
2010-11-16 19:36:11 +01:00
|
|
|
char * error_result = NULL;
|
|
|
|
gtk_label_set_text(GTK_LABEL(handler_context->error_label), NULL);
|
|
|
|
|
2010-07-14 10:44:57 +02:00
|
|
|
+ lock_screen();
|
2010-11-16 19:36:11 +01:00
|
|
|
if (handler_context->hibernate_UPower)
|
|
|
|
error_result = dbus_UPower_Hibernate();
|
2010-07-14 10:44:57 +02:00
|
|
|
else if (handler_context->hibernate_HAL)
|
2010-12-04 20:07:37 +01:00
|
|
|
@@ -236,6 +252,7 @@ static void switch_user_clicked(GtkButton * button, HandlerContext * handler_con
|
2010-07-14 10:44:57 +02:00
|
|
|
{
|
2010-11-16 19:36:11 +01:00
|
|
|
gtk_label_set_text(GTK_LABEL(handler_context->error_label), NULL);
|
|
|
|
|
2010-07-14 10:44:57 +02:00
|
|
|
+ lock_screen();
|
|
|
|
if (handler_context->switch_user_GDM)
|
|
|
|
g_spawn_command_line_sync("gdmflexiserver --startnew", NULL, NULL, NULL, NULL);
|
|
|
|
else if (handler_context->switch_user_KDM)
|