summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorNick Schermer <nick@xfce.org>2012-04-13 19:31:42 +0200
committerNick Schermer <nick@xfce.org>2012-04-13 19:31:42 +0200
commit597a19ad0af55978b2d98cb94874901921ffb5dd (patch)
tree6fd47aed698f7c242156e41244cf0b98ffc606cb /scripts
parent5992ea6bbfd19ec44df276e704b403320cfe6779 (diff)
downloadxfce4-session-597a19ad0af55978b2d98cb94874901921ffb5dd.tar.gz
Improve xflock4 script (bug #3770).
Diffstat (limited to 'scripts')
-rw-r--r--scripts/xflock439
1 files changed, 29 insertions, 10 deletions
diff --git a/scripts/xflock4 b/scripts/xflock4
index fcf33236..ec4d05d4 100644
--- a/scripts/xflock4
+++ b/scripts/xflock4
@@ -3,6 +3,8 @@
# xfce4
#
# Copyright (C) 1999, 2003 Olivier Fourdan (fourdan@xfce.org)
+# Copyright (C) 2011 Guido Berhoerster (guido+xfce.org@berhoerster.name)
+# Copyright (C) 2011 Jarno Suni (8@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