Skip to content

Instantly share code, notes, and snippets.

@afresh1
Created May 15, 2016
Embed
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.
#!/bin/sh
if ! pgrep xlock >/dev/null 2>&1; then
xlock -lockdelay 0 &
sleep 1
fi
sudo -k
ssh-add -D
~/bin/monitors_off &
#!/bin/sh
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
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment