Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.4: A simple alarm clock that plays an iTunes playlist Apps
Tiger only hintI was looking for a way to use my computer as an alarm clock. (I don't like my local radio stations.) I checked out several of the software packages available, and none of them worked for me. I wanted something that would start up the computer and play a playlist from iTunes.

After some experimentation, I discovered a way to do this using Automator, iTunes, and the Energy Saver Preference panel. Plus it was free.

In Automator, create this workflow:
  1. Finder > Launch Application > iTunes
  2. iTunes > Get Specified iTunes Items > Select Desired Playlist
  3. iTunes > Play iTunes Playlist
Save the completed workflow as an application, and then switch to the Finder. Drag the saved Automator application onto the Dock, control-click on it in the Dock, and select Open at Login from the pop-up menu.

Now open the Energy Saver Preference Panel, click on Schedule, and set Start up or Wake to whatever time you want the alarm start playing.
  • Currently 3.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (3 votes cast)

10.4: A simple alarm clock that plays an iTunes playlist | 23 comments | Create New Account
Click here to return to the '10.4: A simple alarm clock that plays an iTunes playlist' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.4: A simple alarm clock that plays an iTunes playlist
Authored by: DocMan on Apr 19, '06 08:19:15AM

You can also do this with Applescripts.

I've created an Applescript that activates iTunes, selects a specific playlist, and then does a fade-up over a period of 10 minutes. It then plays the playlist for an hour, then stops iTunes.


[ Reply to This | # ]
10.4: A simple alarm clock that plays an iTunes playlist
Authored by: filmsmith on Apr 19, '06 08:37:14AM

I've done this, too. I used to use Jon's Commands to assign a hot-key for snooze and for stop, but it quit working under my Intel mac.

An earlier version of my script actually changed to a playlist of more intense songs (i.e. Rage Against the Machine) after about 45 minutes and cranked up the volume. Damn handy after too many late nights.


[ Reply to This | # ]
Automate with crontab
Authored by: sblowes on Apr 19, '06 08:56:00AM
Rather than restarting your computer at a certain time (I've not had much success with that) you can set up a repeating event from the unix side of you OS X:

Save your automator script as an application, ( in /Applications
Open up terminal from /Applications/Utilities/
type in crontab -e at the command line
hit the letter i to get to insert mode
type in the following: 30 6 * * * open /Applications/ to wake up at 6:30am
hit esc
Type in ZZ (two capital Z's)
type in exit and you're done!

Alternately you can get Cronnix which has a neat OS X interface without having to type in all those commands, and it's a great way to automate timed events.
You can also google crontab tutorial and read up on this great little app running on your Apple. It might be handy to learn the basics of Vi which is the default text editer that crontab uses. Learning these things will take you to the next level of geekiness!

To err is human, to moo is bovine

[ Reply to This | # ]

Automate with crontab
Authored by: DocMan on Apr 19, '06 09:17:02AM

Actually, I use a recurring iCal event to schedule my AppleScript. That way I can change the schedule on days I need to get up early, or delete the alarm on days I can actually sleep in.

But I use Cronnix to automate other stuff.

I think the original poster was using the login function because they aren't in the habit of leaving their computer on 24/7/365. I leave my computers up and running.


[ Reply to This | # ]
Automate with crontab
Authored by: brw3sbc on Apr 19, '06 01:48:06PM

24/7/365 ???

24/7/52 or 24/365

[ Reply to This | # ]
10.4: A simple alarm clock that plays an iTunes playlist
Authored by: badger brigade on Apr 19, '06 08:28:35AM

I used to use iTaf, but it doesn't always start the music playing any more. If it was updated to work again, that would be ideal.

[ Reply to This | # ]
10.4: A simple alarm clock that plays an iTunes playlist
Authored by: larley on Apr 19, '06 11:37:24PM

It works fine... I use it every day to wake up. Just be sure your itunes playlist has music in it. Other than that it seems to always work. Unless you start messing with settings. Then it can go wonky. Try deleting your preferences file, going for a new install and try again.

[ Reply to This | # ]
Why reinvent the wheel?
Authored by: Slash on Apr 19, '06 08:33:15AM

Alarm Clock 2

[ Reply to This | # ]
Why reinvent the wheel?
Authored by: solipsism on Apr 19, '06 10:58:17AM
When I saw the title in my RSS feed I thought was going to be about Alarm Clock 2.

It's really a great little program. It sits quietly in your menu bar, you can set up an alarm for daily or weekly routines or a one time reminder in a few seconds. It pulls from your iTunes playlist without needing to first launch iTunes, and can even wake your computer to trigger the alarm (note: this will not function if you closed the lid of your noebook).

If you are looking for a simple, yet robust alarm clock check out Alarm Clock 2. I'm sure you'll love it. BTW, it's FREE!

[ Reply to This | # ]
Why reinvent the wheel?
Authored by: TomAlperin on Apr 19, '06 09:25:56PM

Because Alarm Clock 2 doesn't open iTunes. The method it uses to play music is not compatible with Airtunes over Airport Express units. Maybe I want to wake up the whole house. :P

[ Reply to This | # ]
Why reinvent the wheel?
Authored by: Smokenaxes on Apr 23, '06 05:09:14PM

How about iTunes Alarm? I like it and think it works wonderfully. Check out the link to the developer.

[ Reply to This | # ]
10.4: A simple alarm clock that plays an iTunes playlist
Authored by: skigil on Apr 19, '06 08:54:04AM

Instead of making the script an application, can't you just make it an iCal plug-in? that way you can schedule when you want to wake up in iCal.

[ Reply to This | # ]
10.4: A simple alarm clock that plays an iTunes playlist
Authored by: hereward on Apr 20, '06 09:09:56AM

Exactly right. I use iCal to start the file for WCPE radio; you can start the file for any online station out there -

[ Reply to This | # ]
10.4: A simple alarm clock that plays an iTunes playlist
Authored by: inemo on Apr 19, '06 09:15:27AM

Shameless plug for a good application

My mate Nick's written an application that will do this, and integrates with iCal. Its called iTunesleep, and you can grab it here. Go check it out, its quite an amazing app for Applescript. (Its quite an amazing app in itself actually!)


I'm just a mac baby :)

[ Reply to This | # ]

10.4: A simple alarm clock that plays an iTunes playlist
Authored by: kinnell on Apr 19, '06 09:54:28AM
I have a recurring iCal event which opens the following script:-

set volume output volume 100
set randomTrack to random number 500
tell application "iTunes"
	play track randomTrack of playlist "Library"
end tell
Change "Library" to the playlist of you choice, and 500 to a number less than or equal to the size of the playlist. If anyone knows how to determine the number of tracks in a playlist automatically, I'd love to hear about it :)

Another alternative would be to use launchd, or cron if you're old fashioned.

[ Reply to This | # ]

10.4: A simple alarm clock that plays an iTunes playlist
Authored by: openart2001 on Apr 19, '06 10:16:04AM

If iTunes is actively playing, you can ask iTunes to do the track counting for you in this manner:

tell application "iTunes"
set thisPlaylist to the current playlist
set totalTracks to the count of tracks of thisPlaylist
end tell

[ Reply to This | # ]
10.4: A simple alarm clock that plays an iTunes playlist
Authored by: sjmills on Apr 19, '06 11:58:18AM
Use the "some" keyword to pick a random object:

play some track of playlist "Library"

That way you don't have to worry about counting them and all that. Let iTunes do it for you!

[ Reply to This | # ]

10.4: A simple alarm clock that plays an iTunes playlist
Authored by: TomAlperin on Apr 20, '06 08:15:44PM

I liked the idea of using iCal, but it was easy enough to use automator to get the same results without having to worry about how many tracks are in the playlist and changing the script every time I add tracks.

One thing does still bother me about using iCal this way. I can make one repeating event that only applies to certain days of the week and it's not a problem that my computer wakes up when there really isn't an alarm to play as it will simply go back to sleep in a few minutes, but what are you supposed to do if you have a later or earlier wake-up time a couple days a week? It would be nice if iCal could wake my portable as long as the screen was up. I suppose I could use the desktop to send music through Airtunes to the speakers in my room, setting it to never go to sleep, but that's going to be torture if I need to walk into an entirely different room to turn the music off. Yes, I can use the remote to turn off the speakers, but that eventually will lead to me leaving music running with the speakers muted. All I need is for a cordless phone/microwave incident to switch things back to computer speakers and I've got a nasty phone call from home right in the middle of work.

If it's possible to communicate with iCal through Applescript, it should be possible to write a program that will check to see what the next iCal alarm is and wake the computer so that whatever the alert is occurs at the appropriate time instead of the next time you manually wake the computer.

If not this, it sure would be nice if you could at least have different wake times for different days.

[ Reply to This | # ]
Script ideas
Authored by: callefjant on Apr 19, '06 12:40:30PM

A few ideas, for those who may find it interesting:

I have a repeating event in iTunes that invokes an AppleScript every weekday morning. I usually have it set to 8:00 am but I can change the time individually for any day I want. The script first checks with Salling Clicker or BluePhone Elite that I'm actually at home (if my phone is at home, I probably am as well). Sometimes I more or less accidently sleep elsewhere or I just went out before the alarm is triggered, and I don't wan't to have my neighbours to listen to some crapy bad music all day if I'm not at home.

If one uses Clicker and if Clicker supports proximity for the device, it's an easy task. The device I use since a few weeks ago, a Nokia 6280, is not fully supported by Clicker, but instead by BluePhone Elite. I've told BluePhone Elite to print 'false' to a file when I go out of range and print 'true' when I return.

If I'm home, the script checks the system volume and the iTunes ditto so that it's all loud enough to wake me up. Finally it fades in the currently paused track (or the first track in the playlist, if I've forgotten to set some nice wake up-music before going to bed).

It could probably be even more slicker, but this works for me.

-- If one uses Blue Phone Elite (remove if not used)
set theFile to alias ((path to library folder from user domain as text) & "iApps:is_home") as text
set the target_file to the theFile as text
set the open_target_file to open for access file target_file
set fileContent to (read open_target_file)
close access the open_target_file
set is_home to (fileContent is "true")

-- If one uses Salling Clicker (remove if not used)
tell application "SEC Helper"
set is_home to (proximity state of terminal 1 is within proximity)
end tell

if is_home then
get volume settings
set sysVol to output volume of the result
if ((sysVol / 100) * 7) < 1 then set volume 1
tell application "iTunes"
set myVol to sound volume
if myVol < 20 then set myVol to 20
set sound volume to 0
repeat with i from 0 to myVol
set sound volume to i
delay 0.1
end repeat
end tell
end if

[ Reply to This | # ]
Script ideas
Authored by: xSmurf on Apr 19, '06 04:49:00PM

Wow this is a great idea. Dunno why I didn't think of this before. Now I only need to fix my sound output problem. I've made an apple script to switch to the iMic for audio output (The iMic is routed to my bedroom). Works fine... except when I'm not in front of the computer, in which case the script totally messes up and refuses to change audio output. So although I have a completely automated alarm system (I only need to enter my school schedule once every semester) I still need to switch audio outputs every night or I'm doomed!

PM G4 DP 800 / 1.25gb / 120Gb+80Gb / CD/DVD±RW/RAM/DL
- The only APP Smurf

[ Reply to This | # ]
Script ideas
Authored by: Batshua on May 24, '06 03:31:55PM

If you'll forgive me, I'm not up on my AppleScripting at all. What do your proximity scripts say?

[ Reply to This | # ]
Authored by: earthsaver on Apr 19, '06 07:46:52PM
I far and away prefer the simple interface of iRooster.

- Ben Rosenthal
Q16 1.25 - Tiger

[ Reply to This | # ]

10.4: A simple alarm clock that plays an iTunes playlist
Authored by: Frig on Apr 30, '06 04:38:26AM

I've also written an AppleScript, which invokes iTunes and a special playlist. It also checks if the playlist is existent and if not creates one.

I'm currently using it with iCal where I've alarms which start this script.

This AppleScript has some features which are deactivated at the moment. For example if the playlist has no items, it could search the library for a text and add the the tracks to the playlist, which match the text.
Another feature you could use is that it checks every 10 seconds if you're awake (if you stopped or paused the iTunes) and do an action.

Just feal free to modify and/or use the Applescript

set playlistname to "alarm clock"
set volume 10
say "Good morning!"
tell application "iTunes"
--set minimized of browser window 1 to false
set sound volume to 100
set view of front window to user playlist "Wecker"
if duration of playlist "Wecker" = 0 then
--set view of front window to library playlist
--set mytracks to search library playlist for "some text"
--duplicate every track of mytracks to user playlist playlistname
duplicate every track of library playlist 1 to user playlist playlistname
end if
play playlist playlistname
set song repeat of current playlist to all
set advertisetime to 30
set awake to false
repeat while awake = false
--say "Get up!"
set x to 1
repeat while (x < advertisetime)
delay 10
set x to (x + 1)
if player state is paused or player state is stopped then
set awake to true
exit repeat
end if
end repeat

end repeat*)
end tell
on error
display dialog "Error on executing Alarm!"
end try

[ Reply to This | # ]