Created
September 2, 2014 19:42
-
-
Save hughes/0c072bf7c9ec23d9f2c7 to your computer and use it in GitHub Desktop.
Abandoned laptop email script
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
#!/bin/bash | |
idletime=$((1000*60*5)) # 5 minutes in milliseconds | |
idleMessageSent=0 | |
while true; do | |
idle=`xprintidle` | |
if [[ "$idle" -gt "$idletime" ]]; then | |
if [[ "$idleMessageSent" -eq 0 ]]; then | |
if (gnome-screensaver-command -q | grep "is active"); then | |
echo "your laptop is abandoned" | mail -s 'idle laptop!' hughes@tophat.com | |
# or, if you're evil... echo "I'm buying lunch!" | mail -s 'Hey guys' dev@tophat.com | |
idleMessageSent=1 | |
fi | |
fi | |
else | |
idleMessageSent=0 | |
fi | |
sleep 1 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
todo: replace nested
ifs
withands