[HOWTO] - Make iCal an alarm clock!

boi

official breaker of macs.
are you tired of all those mp3 alarm clock programs that don't fit your needs exactly?
well, it's time to harness the power and ease of use of applescript, the way apple intended. iCal's ability to open a program at certain times makes for a very powerful application, if used in conjunction with applescript.

let's say you're like me and listen to music at night to help you sleep at night. you've probably got a sleepy time playlist or something of the sort.
you'll need one script to hush itunes when you're sound asleep, and one script to start it again when you need to wake up.
------------------------------------
"hush itunes"
tell application "iTunes"
set myVol to sound volume
repeat until (myVol = 0)
set myVol to myVol - 0.25
set sound volume to myVol
end repeat
pause
end tell

this simple script just fades out whatever you're listening to (change the 0.25 to something even smaller if you want it to fade slower) and pauses itunes.
easy enough.
------------------------------------
"wake me up itunes"
tell application "iTunes"
set sound volume to 20
play playlist "wake up"
end tell
set volume 6

this script sets the itunes volume to 20 (out of 100) and sets the system volume to 6 (6 bars on the bezel). this is enough to wake me up-- i've got room mates and soundsticks, so i can't have it too loud.

save both of these scripts and open up ical. tell ical to open your first script at around 3AM or whenever you're sure you'll be sound asleep. next tell ical to open your other script when you want to wake up.
easy as that! a fully customizable alarm clock! hooray!

anyway, yeah. this was probably obvious to most people, but i'm surprised how many 'alarm clock' applications there are, when the best one is right under your nose!
 
Hmm... Well: I don't want to clutter my calendar(s) with daily alarmclock stuff, but I'm sure there are many people who appreciate this howto! ... Also: There are probably more uses for this, too - and this howto is a great start.
 
just make a calendar called "wake up idiot" or whatever, then hide it =) that's what i did anyway.
 
I have wanted to know how to do this for a long time. Is there some way to do it without iCal, where Applescript does the tell at a certain time? i have always wondered.
 
well, stupid question i guess, but is it possible for the computer to go to sleep between the sessions(read; fadeout and wake-up)?? or does it has to been only screensaver-mode or whatever..

and how exactly do i "tell to to iCal" to open the script? just paste it into my calender at prefered time, or is it more to it?

alex.
 
If you're really lazy or stumped, theres several pre-written scripts and applet plugin things on versiontracker for this, all with slogans like "make iTunes and alarm clock!" and similar things. You could probably just download and config one of those....
 
You all should check out iTaf. It has rid of the frustration (largely do to user error) involved in manually setting an alarm clock every nite.

<< Jonathan
 
or you could set an ical alarm to open up a song file (opening with itunes) and that would be that.

My alarm opens up some system of a down for me. That wakes me up very fast.
 
Hi,

I am very new to the mac world and am a little confused. Could someone please give me detailed instructions on how to do this from start to finish.

Thanks
 
JonDVD, if you're still interested in the tip as boi has outlined, try this:

1) Open the Script Editor program (Hard Drive > AppleScript > Script Editor)

2) Create a new AppleScript (Script Editor should have a blank one open the first time you start it).

3) Copy this code into the main text area:
tell application "iTunes"
set myVol to sound volume
repeat until (myVol = 0)
set myVol to myVol - 0.25
set sound volume to myVol
end repeat
pause
end tell
4) Click on the Compile button (you should not get any errors and Script Editor should color and format the code). Test the script by playing iTunes so you can hear it, then click on the Run button in Script Editor. If iTunes' volume fades away and pauses, the script works.

5) Save this AppleScript as "Hush iTunes" or whatever you want. Remember where you saved it, as you'll need to open this file via iCal later.

6) Repeat steps 2 through 5 for this code (and name the file "Wake Me Up iTunes"):
tell application "iTunes"
set sound volume to 20
play playlist "wake up"
end tell
set volume 6
NOTE: You will need to have an iTunes playlist called "wake up" for this script to work!

7) Open iCal. Create a new Calendar and name it "Alarm". Create 2 events - one for waking up and one for fading the music to go to sleep.

8) Click on the "alarm" option and choose "Open file". Choose the AppleScript files (Wake Me Up iTunes and Hush iTunes) for the proper event. I changed the default "15 minutes before" to 0 for a more straight-forward approach.

9) Assign a repeating schedule as appropriate under the "repeat" option for each event.

It should work!
 
ApeintheShell said:
Could you make an automator plug-in for us? Just wondering.
If you're asking me, I'm going to have to respectfully decline. I don't have a lot of free time, plus I have no experience with Automator.
 
My first two attempts at building actions for Automator. Hope they work, let me know if they don't.

I used the scripts exactly as above. If you want to check the source, I've included them in a separate attachment.

[EDIT]
Crap. I didn't read the documentation on actions properly before I built them. If they work it'll be a bloody miracle, I'll get back to this tomorrow, I don't have more time to mess them up further tonight... ::evil::

If any of you want to give it a go, download the Project files, and fix the input thing (I forgot that).
[/EDIT]
 

Attachments

  • Actions.zip
    18.8 KB · Views: 0
  • Project files.zip
    65.4 KB · Views: 0
Back
Top