Skip to content

Instantly share code, notes, and snippets.

@hughes
Created September 2, 2014 19:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hughes/0c072bf7c9ec23d9f2c7 to your computer and use it in GitHub Desktop.
Save hughes/0c072bf7c9ec23d9f2c7 to your computer and use it in GitHub Desktop.
Abandoned laptop email script
#!/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
@hughes
Copy link
Author

hughes commented Sep 2, 2014

todo: replace nested ifs with ands

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment