[Xfce4-commits] <xfce4-session:master> Improve xflock4 script (bug #3770).

Nick Schermer noreply at xfce.org
Fri Apr 13 19:32:01 CEST 2012


Updating branch refs/heads/master
         to 597a19ad0af55978b2d98cb94874901921ffb5dd (commit)
       from 5992ea6bbfd19ec44df276e704b403320cfe6779 (commit)

commit 597a19ad0af55978b2d98cb94874901921ffb5dd
Author: Nick Schermer <nick at xfce.org>
Date:   Fri Apr 13 19:31:42 2012 +0200

    Improve xflock4 script (bug #3770).

 scripts/xflock4 |   39 +++++++++++++++++++++++++++++----------
 1 files changed, 29 insertions(+), 10 deletions(-)

diff --git a/scripts/xflock4 b/scripts/xflock4
index fcf3323..ec4d05d 100644
--- a/scripts/xflock4
+++ b/scripts/xflock4
@@ -3,6 +3,8 @@
 #  xfce4
 #
 #  Copyright (C) 1999, 2003 Olivier Fourdan (fourdan at xfce.org)
+#  Copyright (C) 2011       Guido Berhoerster (guido+xfce.org at berhoerster.name)
+#  Copyright (C) 2011       Jarno Suni (8 at iki.fi)
 #
 #  This program is free software; you can redistribute it and/or modify
 #  it under the terms of the GNU General Public License as published by
@@ -19,13 +21,30 @@
 #  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 #
 
-if test x"`which xscreensaver-command 2>/dev/null`" != x""; then
-    xscreensaver-command -lock 
-elif test x"`which gnome-screensaver-command 2>/dev/null`" != x""; then
-    gnome-screensaver-command --lock
-elif test x"`which slock 2>/dev/null`" != x""; then
-   slock
-else
-    xlock $*
-fi
-exit 0
+PATH=/bin:/usr/bin
+export PATH
+
+# Lock by xscreensaver or gnome-screensaver, if a respective daemon is running
+for lock_cmd in \
+    "xscreensaver-command -lock" \
+    "gnome-screensaver-command --lock"
+do
+    $lock_cmd >/dev/null 2>&1 && exit
+done
+
+# else run another access locking utility, if installed
+for lock_cmd in \
+  "xlock -mode blank" \
+  "slock"
+  do
+    set -- $lock_cmd
+    if command -v -- $1 >/dev/null 2>&1; then
+        $lock_cmd >/dev/null 2>&1 &
+	# turn off display backlight:
+	xset dpms force off
+        exit
+    fi
+done
+
+# else access locking failed
+exit 1


More information about the Xfce4-commits mailing list