[ltp] lock terminals by bringing the lap into sleep mode

Benjamin Weste Pearre linux-thinkpad@linux-thinkpad.org
Tue, 2 Mar 2004 15:42:56 -0700


It's not much, but here's an idea to get you going:

/etc/apm/resume.d/20xscreensaver -> /etc/apm/scripts.d/xscreensaver
/etc/apm/suspend.d/00xscreensaver -> /etc/apm/scripts.d/xscreensaver
/etc/apm/scripts.d/xscreensaver:

#!/bin/sh
export XAUTHORITY=`cat /tmp/xauthority`
export DISPLAY=":0"

case "${1},${2}" in
(suspend,*)
    # This line can be here or below; if here you need
    # /etc/amp/suspend.d/foo to link to this scipt as well
    xscreensaver-command -lock
    ;;
(resume,suspend)
    xscreensaver-command -lock
    # If you just want to wake up the screensaver on resume, this line
    # can be nice:
    # xscreensaver-command -deactivate
    ;;
esac
exit 0

-------

Note that this is a horrible hack, so bad that I should not have
posted it.  It's probably terribly insecure in n ways, n>>1.  Also,
some startup script will have to say something like "echo $XAUTHORITY
> /tmp/xauthority ; chmod 600 /tmp/xauthority": gdm under Debian sets
XAUTHORITY to this value when you log in, and the above script (which
runs as root) needs to know where to find it and be able to read it
(usually not a problem!).

I left in the standard suspend/resume case statement so I could
include the "-deactivate" line where it should be, and so you can
immediately see some more possibilities.

Please, someone, come up with something better.

Cheers :)
-Ben

-- 
Ben Pearre          http://hebb.mit.edu/~ben       PGP: CFDA6CDA
Don't let Bush read your email!             http://www.gnupg.org