Skip to content

Instantly share code, notes, and snippets.

@netj
Created May 17, 2010 06:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save netj/403477 to your computer and use it in GitHub Desktop.
Save netj/403477 to your computer and use it in GitHub Desktop.
Take-a-Break script for the Mac user's health
#!/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 <netj@sparcs.org>
# 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