Skip to content

Instantly share code, notes, and snippets.

@afresh1
Last active August 29, 2015 14:07
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save afresh1/c334372b05c3288dcdd8 to your computer and use it in GitHub Desktop.
Save afresh1/c334372b05c3288dcdd8 to your computer and use it in GitHub Desktop.
A set of scripts to lock my screen and turn off the laptop screen
#!/bin/sh
if ! pgrep xlock >/dev/null 2>&1; then
xlock -lockdelay 0 -endCmd ssh-add &
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