I'm a deep sleeper and I can learn to sleep through any alarm that just beeps, so I wanted wake up to my music instead - dynamic, melodic, pleasant, and I can change it every day. Since all my favorite music is on my computer, I can pick the most pleasant sound to wake up to (Jolie Holland singing "Sascha", or the opening to a Toots and the Maytals concert, or U2 singing "Beautiful Day". I still sleep through the Beatles' "Here comes the sun").
The fact that I can listen to my own music makes this wayyy better than a clock radio.
I've been using this since I was ~12 or so. That's a lot of mornings spent reliability-testing this alarm clock by waking up on time for school, work, etc., until the advent of the Sunshine Alarm Clock I built last year.
*nix users can apply this easily to xmms (I've done it, it works). Windows users, switch to a better operating system, or hang on to your seats and maybe you'll one day be able to script your OS. These directions are for Mac OS/iTunes users.
thanks to Rachel Darman for the photos!
Step 1: Cron
Cron is a utility that makes something happen at a specific time. (think Chronos, the greek god of time)
Here's what you do:
Get into your root-suit by typing "sudo", and sic your favorite text editor on /etc/crontab.
That is, run "sudo emacs /etc/crontab" at the command prompt.
If your crontab is pristine, you should see the first image.
Allow me to explain what all this means.
"# minute hour mday month wday who command"
These are column headings, like in a table. Just insert the time you want into the row below, your username, and the command.
You can add any number of rows. The "command" line will be run verbatim, just as if you were typing it onto the command line.
If a particular time doesn't matter, use a * (wildcard).
For example, if you only specify a minute (e.g., "15"), and fill in the rest of the colums with '*'s, that command will run every hour on the 15 minutes.
If you put a * for the minute, the command will run every minute. It's rare that you'd want to do that, unless for some kind of prankery.
mday is a particular date (e.g., "14" to run on the 14th of every month), wday is a day of the week (0-6, e.g, "0" for Sunday).
Dig it a lot? Learn more by running "man crontab" and "man cron" at your terminal.
Step 2: Convention
Mac OS lets you access GUI programs by running the "open" command.
So, to launch iTunes, you'd run "open -a iTunes". This also brings iTunes to the front as the active window. Even if it's already open.
Other *nixen allow you to simply run the name of the program's binary, e.g. "xmms".
The particularly cool thing about Mac OS is applescript, which lets you do a whole lot more than just open applications. You can run applescript one-liners with the "osascript" command.
So, to start iTunes playing, you'd run "osascript -e 'tell app "iTunes" to play'".
This does the same thing as hitting the play button on whichever playlist window you have open.
You can start and stop iTunes, modulate the volume, and more.
Sometimes I liked to fall asleep with a playlist playing, and wake up to a different one.
Specifiying a particular playlist is easy:
"osascript -e 'tell app "iTunes" to play playlist "morning music"' "
the playlist is not case-sensitive.
Step 3: Pitfalls
I've had my share of mornings, where, for some reason, the alarm "didn't go off". Usually my computer speakers were off or turned down too low, or my system volume was muted because I was doing something late at night and didn't want to wake up my roommate.
You can ensure that your volume is up on your computer by running "osascript -e 'set volume 10'".
Add that to your crontab, and your volume will always be up when you need it to be.
Other times, I've asked my computer to wake me up to music streams from the internet while I had no internet connection, which doesn't work. So I usually make wakeup playlists out of music files I have stored locally.
Step 4: Synthesis
# minute hour mday month wday who command
00 9 * * * stasterisk osascript -e 'tell app "iTunes" to play playlist "Coffee"'
When you're done, you can make the alarm not play any more by adding a "#" to the beginning of the line to comment it out. Do this if you're traveling, or might be leaving your computer in a room where other people sleep, but you won't be around to turn off the music, etc.
For *nixen, run "xmms filename".
If you want to make a movie play in quicktime instead, say, your favorite clip of the NBA finals where Michael Jordan makes the 3-point shot in the last second just as the buzzer sounds, substitute the commands with "open -a "Quicktime Player" filename.mov" and "osascript -e 'tell app "QuickTime Player" to play document 1'".
There you have it! Easy one-line custom music alarm clock! Enjoy waking up!
Now you can listen to any music you want, including The Zombeatles!!