Skip to content

Instantly share code, notes, and snippets.

@Ferdi265
Created October 14, 2015 21:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ferdi265/395448f598b6cf4adc30 to your computer and use it in GitHub Desktop.
Save Ferdi265/395448f598b6cf4adc30 to your computer and use it in GitHub Desktop.
xautolock control wrapper script
#!/bin/bash
xlenable() {
echo enabled > /tmp/xlmode-$DISPLAY
[[ "$1" != "-quiet" ]] && notify-send "xautolock" "Automatic locking enabled"
xautolock -enable
}
xldisable() {
echo disabled > /tmp/xlmode-$DISPLAY
[[ "$1" != "-quiet" ]] && notify-send "xautolock" "Automatic locking disabled"
xautolock -disable
}
xltoggle() {
[[ $(cat /tmp/xlmode-$DISPLAY) = enabled ]] && xldisable $1 || xlenable $1
}
case $1 in
now) xlenable -quiet; exec xautolock -locknow;;
enable) xlenable $2;;
disable) xldisable $2;;
toggle) xltoggle $2;;
*) echo $0: No such option
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment