Skip to content

Instantly share code, notes, and snippets.

@shaiay
Created September 23, 2015 19:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shaiay/283a117d81890d85930b to your computer and use it in GitHub Desktop.
Save shaiay/283a117d81890d85930b to your computer and use it in GitHub Desktop.
a screen locker for use with xautolock which enables locking without password when connected to home wifi
#!/bin/sh
#
# example usage:
# xautolock -locker /full/path/to/screenlock.sh -corners 00-+ -detectsleep
#
# depends on xssstate which is part of suckless-tools:
# http://tools.suckless.org/ or
# apt-get suckless-tools on debian
#
simple_lock () {
# lock w/o password & don't exit until screen save turns off to comply with
# xautolock expected locker behaviour
xset s activate
sleep 1
while [ $(xssstate -s) = "on" ]; do
sleep 1
done
}
passwd_lock () {
# use whatever you like here
i3lock --dpms --color=222222
}
connection=$(nmcli d show wlan0 | grep GENERAL.CONNECTION | awk '{print $2}')
if [ "$connection" = "my_ssid" ] ; then
simple_lock
else
passwd_lock
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment