Fancy command-line alarm for Mac OS X

I have a Calc exam in the morning. Instead of studying for it, I decided to program a command-line alarm for myself so I don’t sleep through the exam. It doesn’t help that my phone is MIA and I’ve never owned a regular alarm clock.

Here:


#!/bin/bash
osascript -e 'tell app "iTunes" to pause' > /dev/null
osascript -e "set Volume 3"
say "Wake up, Josh. Time to get out of bed. You have an exam to take."
sleep 5
osascript -e "set Volume 0.5"
osascript -e 'tell app "iTunes" to play playlist "morning music"' > /dev/null
sleep 5
osascript -e "set Volume 1"
sleep 5
osascript -e "set Volume 1.5"
sleep 5
osascript -e "set Volume 2"
sleep 5
osascript -e "set Volume 2.5"
sleep 5
osascript -e "set Volume 3"

Save it in your ~/bin folder, reference it from your crontab, set up a “Morning music” playlist in iTunes and customize the wakeup message. Also, the tiered volume is fun but really janky.

And my crontab, IN CASE YOU WONDERED:


0 8 * * mon,tue,wed,thu,fri ~/bin/alarm.sh > /dev/null
30 8 * * mon,tue,wed,thu,fri ~/bin/alarm.sh > /dev/null
0 9 * * sat,sun ~/bin/alarm.sh > /dev/null
30 9 * * sat,sun ~/bin/alarm.sh > /dev/null

A snooze feature would be nice, but that can wait.

This entry was posted in Coding, News, Personal. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>