forked from pool/lxsession
- take a different approach to locking the screen, execute a lxlock
script asynchronously, this solves the problem with xlock and slock which do not fork and blocked suspend/hibernate OBS-URL: https://build.opensuse.org/package/show/X11:lxde/lxsession?expand=0&rev=45
This commit is contained in:
parent
72bd1dd05e
commit
f032aef3f7
@ -1,6 +1,70 @@
|
|||||||
diff -ur lxsession-0.4.5.orig/lxsession-logout/lxsession-logout.c lxsession-0.4.5/lxsession-logout/lxsession-logout.c
|
diff --git a/Makefile.am b/Makefile.am
|
||||||
--- lxsession-0.4.5.orig/lxsession-logout/lxsession-logout.c 2010-11-14 19:28:18.000000000 +0100
|
index 6e86875..5e53b41 100644
|
||||||
+++ lxsession-0.4.5/lxsession-logout/lxsession-logout.c 2010-11-16 18:59:38.000000000 +0100
|
--- 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
|
||||||
@@ -25,6 +25,7 @@
|
@@ -25,6 +25,7 @@
|
||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@ -9,7 +73,7 @@ diff -ur lxsession-0.4.5.orig/lxsession-logout/lxsession-logout.c lxsession-0.4.
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
@@ -73,6 +74,7 @@
|
@@ -73,6 +74,7 @@ typedef struct {
|
||||||
int ltsp : 1; /* Shutdown and reboot is accomplished via LTSP */
|
int ltsp : 1; /* Shutdown and reboot is accomplished via LTSP */
|
||||||
} HandlerContext;
|
} HandlerContext;
|
||||||
|
|
||||||
@ -17,54 +81,26 @@ diff -ur lxsession-0.4.5.orig/lxsession-logout/lxsession-logout.c lxsession-0.4.
|
|||||||
static gboolean verify_running(char * display_manager, char * executable);
|
static gboolean verify_running(char * display_manager, char * executable);
|
||||||
static void logout_clicked(GtkButton * button, HandlerContext * handler_context);
|
static void logout_clicked(GtkButton * button, HandlerContext * handler_context);
|
||||||
static void change_root_property(GtkWidget* w, const char* prop_name, const char* value);
|
static void change_root_property(GtkWidget* w, const char* prop_name, const char* value);
|
||||||
@@ -85,6 +87,46 @@
|
@@ -85,6 +87,18 @@ static void cancel_clicked(GtkButton * button, gpointer user_data);
|
||||||
static GtkPositionType get_banner_position(void);
|
static GtkPositionType get_banner_position(void);
|
||||||
static GdkPixbuf * get_background_pixbuf(void);
|
static GdkPixbuf * get_background_pixbuf(void);
|
||||||
|
|
||||||
+/* Try to lock the screen, return TRUE on success, FALSE if no suitable
|
+/* Try to run lxlock command in order to lock the screen, return TRUE on
|
||||||
+ * screensaver was found or the screensaver command exited abnormally.
|
+ * success, FALSE if command execution failed
|
||||||
+ */
|
+ */
|
||||||
+static gboolean lock_screen(void)
|
+static gboolean lock_screen(void)
|
||||||
+{
|
+{
|
||||||
+ gint i;
|
+ if (!g_spawn_command_line_async("lxlock", NULL))
|
||||||
+ gint argcp;
|
|
||||||
+ gchar **argvp;
|
|
||||||
+ gint exit_status;
|
|
||||||
+ gchar *locking_commands[] = {
|
|
||||||
+ "xscreensaver-command -lock",
|
|
||||||
+ "gnome-screensaver-command --lock",
|
|
||||||
+ "xlock -mode blank",
|
|
||||||
+ NULL
|
|
||||||
+ };
|
|
||||||
+
|
|
||||||
+ for (i = 0; locking_commands[i] != NULL; ++i)
|
|
||||||
+ {
|
+ {
|
||||||
+ g_shell_parse_argv(locking_commands[i], &argcp, &argvp, NULL);
|
+ return TRUE;
|
||||||
+ g_spawn_sync(NULL,
|
|
||||||
+ argvp,
|
|
||||||
+ NULL,
|
|
||||||
+ G_SPAWN_SEARCH_PATH|G_SPAWN_STDOUT_TO_DEV_NULL|G_SPAWN_STDERR_TO_DEV_NULL,
|
|
||||||
+ NULL,
|
|
||||||
+ NULL,
|
|
||||||
+ NULL,
|
|
||||||
+ NULL,
|
|
||||||
+ &exit_status,
|
|
||||||
+ NULL);
|
|
||||||
+ g_strfreev (argvp);
|
|
||||||
+
|
|
||||||
+ if (WIFEXITED(exit_status) && WEXITSTATUS(exit_status) == 0)
|
|
||||||
+ {
|
|
||||||
+ return TRUE;
|
|
||||||
+ }
|
|
||||||
+ }
|
+ }
|
||||||
+
|
|
||||||
+ return FALSE;
|
+ return FALSE;
|
||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
/* Verify that a program is running and that an executable is available. */
|
/* Verify that a program is running and that an executable is available. */
|
||||||
static gboolean verify_running(char * display_manager, char * executable)
|
static gboolean verify_running(char * display_manager, char * executable)
|
||||||
{
|
{
|
||||||
@@ -205,6 +247,7 @@
|
@@ -205,6 +219,7 @@ static void suspend_clicked(GtkButton * button, HandlerContext * handler_context
|
||||||
char * error_result = NULL;
|
char * error_result = NULL;
|
||||||
gtk_label_set_text(GTK_LABEL(handler_context->error_label), NULL);
|
gtk_label_set_text(GTK_LABEL(handler_context->error_label), NULL);
|
||||||
|
|
||||||
@ -72,7 +108,7 @@ diff -ur lxsession-0.4.5.orig/lxsession-logout/lxsession-logout.c lxsession-0.4.
|
|||||||
if (handler_context->suspend_UPower)
|
if (handler_context->suspend_UPower)
|
||||||
error_result = dbus_UPower_Suspend();
|
error_result = dbus_UPower_Suspend();
|
||||||
else if (handler_context->suspend_HAL)
|
else if (handler_context->suspend_HAL)
|
||||||
@@ -221,6 +264,7 @@
|
@@ -221,6 +236,7 @@ static void hibernate_clicked(GtkButton * button, HandlerContext * handler_conte
|
||||||
char * error_result = NULL;
|
char * error_result = NULL;
|
||||||
gtk_label_set_text(GTK_LABEL(handler_context->error_label), NULL);
|
gtk_label_set_text(GTK_LABEL(handler_context->error_label), NULL);
|
||||||
|
|
||||||
@ -80,7 +116,7 @@ diff -ur lxsession-0.4.5.orig/lxsession-logout/lxsession-logout.c lxsession-0.4.
|
|||||||
if (handler_context->hibernate_UPower)
|
if (handler_context->hibernate_UPower)
|
||||||
error_result = dbus_UPower_Hibernate();
|
error_result = dbus_UPower_Hibernate();
|
||||||
else if (handler_context->hibernate_HAL)
|
else if (handler_context->hibernate_HAL)
|
||||||
@@ -236,6 +280,7 @@
|
@@ -236,6 +252,7 @@ static void switch_user_clicked(GtkButton * button, HandlerContext * handler_con
|
||||||
{
|
{
|
||||||
gtk_label_set_text(GTK_LABEL(handler_context->error_label), NULL);
|
gtk_label_set_text(GTK_LABEL(handler_context->error_label), NULL);
|
||||||
|
|
||||||
|
@ -1,3 +1,10 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Sat Dec 4 19:02:38 UTC 2010 - gber@opensuse.org
|
||||||
|
|
||||||
|
- take a different approach to locking the screen, execute a lxlock
|
||||||
|
script asynchronously, this solves the problem with xlock and
|
||||||
|
slock which do not fork and blocked suspend/hibernate
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Tue Nov 16 18:01:20 UTC 2010 - gber@opensuse.org
|
Tue Nov 16 18:01:20 UTC 2010 - gber@opensuse.org
|
||||||
|
|
||||||
|
@ -48,8 +48,7 @@ Authors:
|
|||||||
%patch0 -p1
|
%patch0 -p1
|
||||||
|
|
||||||
%build
|
%build
|
||||||
export CFLAGS="$RPM_OPT_FLAGS"
|
autoreconf -fi
|
||||||
export CXXFLAGS="$RPM_OPT_FLAGS"
|
|
||||||
%configure --enable-man
|
%configure --enable-man
|
||||||
%__make %{?jobs:-j%jobs}
|
%__make %{?jobs:-j%jobs}
|
||||||
|
|
||||||
@ -65,6 +64,7 @@ rm -rf $RPM_BUILD_ROOT
|
|||||||
%files -f %{name}.lang
|
%files -f %{name}.lang
|
||||||
%defattr(-,root,root,0755)
|
%defattr(-,root,root,0755)
|
||||||
%doc ChangeLog README COPYING
|
%doc ChangeLog README COPYING
|
||||||
|
%{_bindir}/lxlock
|
||||||
%{_bindir}/lxsession
|
%{_bindir}/lxsession
|
||||||
%{_bindir}/lxsession-logout
|
%{_bindir}/lxsession-logout
|
||||||
%dir %{_datadir}/lxsession
|
%dir %{_datadir}/lxsession
|
||||||
|
Loading…
Reference in New Issue
Block a user