Skip to content

Instantly share code, notes, and snippets.

@afresh1
Created May 15, 2016 19:16
Show Gist options
  • Select an option

  • Save afresh1/04fb7c7068b84fbf4dee8428a31f6846 to your computer and use it in GitHub Desktop.

Select an option

Save afresh1/04fb7c7068b84fbf4dee8428a31f6846 to your computer and use it in GitHub Desktop.
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