2010-11-16 19:36:11 +01:00
|
|
|
diff -ur lxsession-0.4.5.orig/lxsession-logout/lxsession-logout.c lxsession-0.4.5/lxsession-logout/lxsession-logout.c
|
|
|
|
--- lxsession-0.4.5.orig/lxsession-logout/lxsession-logout.c 2010-11-14 19:28:18.000000000 +0100
|
|
|
|
+++ lxsession-0.4.5/lxsession-logout/lxsession-logout.c 2010-11-16 18:59:38.000000000 +0100
|
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-11-16 19:36:11 +01:00
|
|
|
@@ -73,6 +74,7 @@
|
|
|
|
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);
|
|
|
|
@@ -85,6 +87,46 @@
|
2010-07-14 10:44:57 +02:00
|
|
|
static GtkPositionType get_banner_position(void);
|
|
|
|
static GdkPixbuf * get_background_pixbuf(void);
|
|
|
|
|
|
|
|
+/* Try to lock the screen, return TRUE on success, FALSE if no suitable
|
|
|
|
+ * screensaver was found or the screensaver command exited abnormally.
|
|
|
|
+ */
|
|
|
|
+static gboolean lock_screen(void)
|
|
|
|
+{
|
2010-07-17 13:04:41 +02:00
|
|
|
+ gint i;
|
|
|
|
+ gint argcp;
|
|
|
|
+ gchar **argvp;
|
2010-07-14 10:44:57 +02:00
|
|
|
+ gint exit_status;
|
2010-07-17 13:04:41 +02:00
|
|
|
+ gchar *locking_commands[] = {
|
|
|
|
+ "xscreensaver-command -lock",
|
|
|
|
+ "gnome-screensaver-command --lock",
|
|
|
|
+ "xlock -mode blank",
|
|
|
|
+ NULL
|
|
|
|
+ };
|
2010-07-14 10:44:57 +02:00
|
|
|
+
|
2010-07-17 13:04:41 +02:00
|
|
|
+ for (i = 0; locking_commands[i] != NULL; ++i)
|
2010-07-14 10:44:57 +02:00
|
|
|
+ {
|
2010-07-17 13:04:41 +02:00
|
|
|
+ g_shell_parse_argv(locking_commands[i], &argcp, &argvp, NULL);
|
|
|
|
+ g_spawn_sync(NULL,
|
|
|
|
+ argvp,
|
2010-07-14 10:44:57 +02:00
|
|
|
+ NULL,
|
2010-07-17 13:04:41 +02:00
|
|
|
+ G_SPAWN_SEARCH_PATH|G_SPAWN_STDOUT_TO_DEV_NULL|G_SPAWN_STDERR_TO_DEV_NULL,
|
2010-07-14 10:44:57 +02:00
|
|
|
+ NULL,
|
|
|
|
+ NULL,
|
|
|
|
+ NULL,
|
|
|
|
+ NULL,
|
|
|
|
+ &exit_status,
|
|
|
|
+ NULL);
|
2010-07-17 13:04:41 +02:00
|
|
|
+ g_strfreev (argvp);
|
2010-07-14 10:44:57 +02:00
|
|
|
+
|
2010-07-17 13:04:41 +02:00
|
|
|
+ if (WIFEXITED(exit_status) && WEXITSTATUS(exit_status) == 0)
|
|
|
|
+ {
|
|
|
|
+ return TRUE;
|
|
|
|
+ }
|
|
|
|
+ }
|
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-11-16 19:36:11 +01:00
|
|
|
@@ -205,6 +247,7 @@
|
|
|
|
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-11-16 19:36:11 +01:00
|
|
|
@@ -221,6 +264,7 @@
|
|
|
|
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-11-16 19:36:11 +01:00
|
|
|
@@ -236,6 +280,7 @@
|
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)
|