From 597a19ad0af55978b2d98cb94874901921ffb5dd Mon Sep 17 00:00:00 2001 From: Nick Schermer Date: Fri, 13 Apr 2012 19:31:42 +0200 Subject: Improve xflock4 script (bug #3770). --- scripts/xflock4 | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) (limited to 'scripts') 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 -- cgit v1.2.1