January 25, 2012
using launchd and growl to show a daily message on Mac OS X
Just spent too much time figuring out how to show a Growl message at a particular time in Mac OS X. Seems like “cron” has been abandoned in place of launchd, so I had to write my first .plist file, which was simpler than expected.
Here are the steps:
1. First install Growl and growlnotify if you need to. (download here). Note for pre-Lion, growlnotify is in Extras in the Growl download.
2. make a script that shows your reminder, such as my schoolClock.sh:
/usr/local/bin/growlnotify -s -m "Time to pick up Isabel!" --appIcon "/Applications/iCal.app"
3. open up “Property List Editor” (which is included in XCode dev tools) and make a plist file in ~/Library/LaunchAgents
I called mine “com.immuexa.schoolClock.plist” and it looks like this:
(click image to see it, note the location and name of the script)
4. run this command in Terminal:
launchctl load -w ~/Library/LaunchAgents/com.immuexa.schoolClock.plist
Do this and you’ll get a message saying “Time to pick up Isabel at 3pm each day”.
For those that don’t have Property List Editor handy, you can use any text editor to create:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>com.immuexa.schoolClock</string> <key>ProgramArguments</key> <array> <string>/Users/immuexa/cmd/schoolClock.sh</string> </array> <key>StartCalendarInterval</key> <dict> <key>Hour</key> <integer>15</integer> <key>Minute</key> <integer>0</integer> </dict> </dict> </plist>