Created
May 17, 2010 06:52
-
-
Save netj/403477 to your computer and use it in GitHub Desktop.
Take-a-Break script for the Mac user's health
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 | |
# take-a-break-with -- Take-a-Break script for the Mac user's health | |
# | |
# Schedule calling this script regularly from your crontab: | |
# | |
# */60 * * * * take-a-break-with Dashboard | |
# | |
# When a Growl bubble comes up, click it and take a break! :) | |
# | |
# You need to get and install Growl from: http://growl.info/ | |
# | |
# Author: Jaeho Shin <[email protected]> | |
# Created: 2010-05-17 | |
set -e | |
App=$1 | |
# show usage if input doesn't look good | |
if [ -z "$App" ] || | |
! mdfind "kMDItemDisplayName = '$App'" \ | |
"kMDItemContentType = com.apple.application-bundle" &>/dev/null; then | |
sed -n '2,/^#$/ s/^# //p' <"$0" | |
false | |
fi | |
# display a Growl message | |
{ | |
cat <<EOF | |
Take a Break! It's already `date +%R` | |
All work and no play makes | |
$LOGNAME dull and sick :( | |
EOF | |
} | | |
growlnotify --name "Take a Break with" \ | |
--identifier take-a-break-with \ | |
--message - --wait --appIcon "$App" | |
# and continue opening the App when dismissed. | |
open -a "$App" | |
# Currently growlnotify can't tell whether the Growl message timed out or not: | |
# http://code.google.com/p/growl/issues/detail?id=123 | |
# So we're taking a workaround that might be less intrusive? :) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment