Skip to content

Instantly share code, notes, and snippets.

@logosity
Created January 15, 2013 20:43
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 logosity/4541861 to your computer and use it in GitHub Desktop.
Save logosity/4541861 to your computer and use it in GitHub Desktop.
toggle screen saver on and off on an xwindows-using linux machine (tested only on Ubuntu)
#!/bin/bash
case "$1" in
on)
/usr/bin/xset -display :0.0 dpms force on
/usr/bin/xset -display :0.0 -dpms
/usr/bin/xset -display :0.0 s off
/usr/bin/xset -display :0.0 s reset
;;
off)
/usr/bin/xset -display :0.0 dpms force off
/usr/bin/xset -display :0.0 dpms 60 90 120
;;
?)
echo "Usage: monitors on|off"
exit 1
;;
*) #toggle
if [[ "$(xset -q -display :0.0 | grep -i 'disabled')" == "" ]]
then $0 on
else $0 off
fi
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment