Periodic Desktop Notifications for Reminders with AppleScript

Sometimes it’s better to use the tools that you already have instead of reinventing the wheel. That was the case with a little application that I needed. Software development is a very¬†sedentary job with many hours spent sitting in front of a computer. I wanted to be reminded to get up and move every hour. I looked into developing a little program that could fire off a desktop notification every hour. On a Mac, this is surprisingly simple with AppleScript. Simply go to Applications -> Utilities -> ScriptEditor and punch in the following script:

display notification "Get up and move!" with title "Time for a Break" sound name "Blow"

Hit the play button to try it out. When satisfied, save it as a script (e.g. “GetUpAndMove.scpt”). Then set it up to run periodically with cron. Run crontab -e¬†and enter the following:

55 * * * * /usr/bin/osascript /Users/your_username_here/GetUpAndMove.scpt

That’s it! A one line script and a one line cron job. The above will send a notification every hour at 5 of.