Last active
August 29, 2015 14:13
-
-
Save starkers/d9eb5bde81e10c473cfd to your computer and use it in GitHub Desktop.
yubiwatch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
ENV="$(env)" | |
if ! grep -q DISPLAY= <<<"$ENV" ; then | |
echo dunno what your DISPLAY= is, setting default and crossing fingers | |
export DISPLAY=:0 | |
fi | |
# simple script that watches for a Yubikey being plugged in.. | |
# | |
# This simply keeps me in the habit of unplugging my key when I leave my desk | |
# | |
# when I unplug it my screensaver will lock, works on mint-cinnamon | |
# my Yubikey shows up as (lsusb) : | |
# | |
# --snip-- | |
# Bus 002 Device 079: ID 1050:0110 Yubico.com | |
# --snip-- | |
while true ; do | |
DATA="$(lsusb)" | |
if grep -q Yubico.com <<<"$DATA" ; then | |
printf 1 | |
else | |
printf 0 | |
gnome-screensaver-command --lock | |
fi | |
sleep 1 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment