Skip to content

Instantly share code, notes, and snippets.

Created May 15, 2016
What would you like to do?
Lock screen and dpms off monitor. I have `command lock "lock_screen"` in ~/.cwmrc and `*/5 * * * * $HOME/bin/monitors_off` in my crontab.
if ! pgrep xlock >/dev/null 2>&1; then
xlock -lockdelay 0 &
sleep 1
sudo -k
ssh-add -D
~/bin/monitors_off &
if pgrep xlock >/dev/null 2>&1; then
DISPLAY=`pgrep -nfl '[ /]X :[0-9]+ vt05' |
sed -e 's/^[^:]*\(:[0-9][0-9]*\)[^0-9].*/\1/'`
if [ X"${DISPLAY}" != X"" ]; then
xset -display ${DISPLAY} dpms force off
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment