Thu, 20 Feb 2014
Automatically unlocking xscreensaver in some locations
When I am at home I do not want to be bothered by the screensaver locking my laptop. To solve this, I use a custom PAM configuration which checks if I am authenticated to the local access point.
Add this to the top of /etc/pam.d/xscreensaver:
auth sufficient pam_exec.so quiet /usr/local/sbin/pam_auth_xscreensaver
And then use a script like this one to decide when you want the display to be automatically unlocked:
#!/bin/sh -e
# return the ESSID of this interface
current_essid() {
/sbin/iwconfig $1 | sed -nre '/ESSID/s/.*ESSID:"([^"]+)".*/\1/p'
}
# automatically unlock only for these users
case "$PAM_USER" in
"") echo "This program must be run by pam_auth.so!"
exit 1
;;
md) ;;
*) exit 1
;;
esac
CURRENT_ESSID=$(current_essid wlan0)
# automatically unlock when connected to these networks
case "$CURRENT_ESSID" in
MYOWNESSID) exit 0 ;;
esac
exit 6