XLock for password protected login and screensaver

How to do things, solutions, recipes, tutorials
Post Reply
Message
Author
wizardshop
Posts: 2
Joined: Mon 11 Sep 2006, 18:10

XLock for password protected login and screensaver

#1 Post by wizardshop »

Here is an option for a system login and password locking screen saver for Puppy. I've got it on my pup_save CD desktop Puppy at work and my laptop HD install at home. Now I can walk away without worry...

This script will run the XLock screen lock program both on boot and if there is no mouse or keyboard activity in TIMEOUT minutes (You can change this in the script - default is 2 minutes). It works under Puppy 2.02 - not sure about others but this really should do ok even on unrelated distros. If you don't have XLock, or if your XLock isn't in the same path, just change the program path to something you can use.

- Changed instructions
This script will purposely hang startup until the first run of XLock completes, then live quietly as a background process waiting for inactivity. To stop it, kill slock.

1: Extract this file into /root with execute permissions
2: add to /root/.xinitrc: /root/slock
before the line: exec $CURRENTWM

Just a warning - test run it from a console before setting up at boot. Play Murphy's law to win... You don't want it to have an issue on boot. Also, make sure you have run XLock and set the password.
This is only 29 lines of simple BASH - mod as you like, this meets my needs but may need some more opts.

Lovin the Pup - He's given me back my once too-slow-for-ANY-OS laptop!

Tom
Attachments
slock.tar.gz
(829 Bytes) Downloaded 799 times
Last edited by wizardshop on Tue 12 Sep 2006, 14:03, edited 1 time in total.

GuestToo
Puppy Master
Posts: 4083
Joined: Wed 04 May 2005, 18:11

#2 Post by GuestToo »

you can check if X is running by checking $DISPLAY ... maybe something like this:

[ -z $DISPLAY ] && CT=0
if [[ $CT -ge $TIMEOUT ]] ; then

Icewm will popup a window with reboot, shutdown, and lock screen choices if ctrl+alt+del is pressed ... but Puppy will reboot if you do that ... Puppy's behaviour could be changed by editing /etc/inittab

wizardshop
Posts: 2
Joined: Mon 11 Sep 2006, 18:10

#3 Post by wizardshop »

Hi GuestToo,

I've tried a few variations on testing for the X server, but they all result in the X app starting too soon. The sysvar DISPLAY does not get set for a currently running script, and the test for X or X :0 as a process is unreliable. Tried them both.
I did miss something though - adding to /root/.xinitrc - and executing before

Code: Select all

exec $CURRENTWM
. Had missed a post by Mark (MU) about this. This location also allows you to log off X and have the startup apps re-run on login. Works for any WM on Puppy. I'm updating the instructions.
BTW - if one day XLock gets the option for"Use as screensaver", this script will be unneccesary.
To only have the boot login with XLock, add

Code: Select all

/usr/local/apps/Xlock/AppRun
to /root/.xinitrc. It is already there so there is nothing to make your puppy bigger.

Not for all, but I want my puppy autolocking at work and I don't want the grandkids mucking about on my computer without me around. Now if I can just teach my MaltePom to type. She likes little puppies...

Tom
Last edited by wizardshop on Tue 12 Sep 2006, 14:30, edited 1 time in total.

GuestToo
Puppy Master
Posts: 4083
Joined: Wed 04 May 2005, 18:11

#4 Post by GuestToo »

duh, i feel stupid

of course $DISPLAY would be set when slock starts executing, and would not be updated

something vaguely like this should work:

pidof X || CT=0
if [[ $CT -ge $TIMEOUT ]] ; then

or

pidof xinit || CT=0

but if you start slock from .xinitrc, you wouldn't need to test for X anyway ... it would start with X and the process would be killed when the parent process (that is, X) is killed

(explanation mostly for others who might read this thread)

Post Reply