! Please note that this is a snapshot of our old Bugzilla server, which is read only since May 29, 2020. Please go to gitlab.xfce.org for our new server !
Add slock as an option in xflock4 script
Status:
RESOLVED: DUPLICATE
Severity:
enhancement
Product:
Xfce-utils
Component:
General

Comments

Description Robby Workman editbugs 2009-03-17 22:29:31 CET
Created attachment 2239 
Add slock to xflock4

In the attached patch, I put slock as the first try - my rationale is that slock is obscure enough that if anyone has it installed, I'd expect that they will prefer to use it.
Comment 1 Yves-Alexis Perez editbugs 2009-03-18 06:45:59 CET
If an user is running (x|gnome-)screensaver this one should be run preferently :)
Comment 2 Robby Workman editbugs 2009-03-18 15:53:01 CET
Created attachment 2241 
Try #2

Good point.  How's this?  (hopefully it's not overcomplicated)
* attached patch implements this version *

if test x"$(which slock 2>/dev/null)" != x"" ; then
    if ! ( ps -fC xscreensaver | grep $USER ) ; then
        if ! ( ps -fC gnome-screensaver | grep $USER ) ; then
            slock
        fi
    fi
elif 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
else
    xlock $*
fi
exit 0
Comment 3 Brian J. Tarricone (not reading bugmail) 2009-03-18 16:05:21 CET
I don't really like grepping through ps output.  'xscreensaver-command -version' will return a nonzero exit status if xscreensaver isn't running, so you can test that.  Should figure out how to do something similar with gnome-screensaver.
Comment 4 Robby Workman editbugs 2009-03-27 16:51:49 CET
Okay, rather than a patch, here's my latest proposal.
It's a few more lines than what is currently present though...

I've got a request for some gnome guys to verify that gnome-screensaver behaves the same as xscreensaver with respect to what -command returns if the daemon isn't running, but assuming it does, I think this will work:

if [ -x $(which xscreensaver-command 2>/dev/null) ]; then
   xscreensaver-command -lock || break
fi

if [ -x $(which gnome-screensaver-command --lock 2>/dev/null) ]; then
   gnome-screensaver-command --lock || break
fi

if [ -x $(which slock 2>/dev/null) ]; then
  slock || break
fi

xlock $*

exit 0
Comment 5 Robby Workman editbugs 2009-03-27 18:37:42 CET
Geez.  Sorry for the bug spam, but I overlooked an obvious problem.  The following should be good now:

if [ -x $(which xscreensaver-command 2>/dev/null) ]; then
   xscreensaver-command -lock || break
   exit 0
fi

if [ -x $(which gnome-screensaver-command --lock 2>/dev/null) ]; then
   gnome-screensaver-command --lock || break
   exit 0
fi

if [ -x $(which slock 2>/dev/null) ]; then
   slock || break
   exit 0
fi

# If none of the above return successfully, then fallback to xlock
xlock $*
exit 0
Comment 6 Robby Workman editbugs 2009-03-27 20:34:50 CET
Created attachment 2257 
Try #3 - hopefully final

After discussion on IRC with Brian, the new patch should be sufficient, I think.
Comment 7 Robby Workman editbugs 2010-02-25 14:15:12 CET

*** This bug has been marked as a duplicate of bug 6253 ***

Bug #5121

Reported by:
Robby Workman
Reported on: 2009-03-17
Last modified on: 2010-02-25

People

Assignee:
Xfce Bug Triage
CC List:
1 user

Version

Attachments

Add slock to xflock4 (706 bytes, patch)
2009-03-17 22:29 CET , Robby Workman
no flags
Try #2 (826 bytes, patch)
2009-03-18 15:53 CET , Robby Workman
no flags
Try #3 - hopefully final (947 bytes, patch)
2009-03-27 20:34 CET , Robby Workman
no flags

Additional information