geekiest alarm clock redux.

As outlined in my other post, I’ve been working on using technology to find an easier way to wake up in the morning. If I had a ton of dough, I might check out this nifty watch (although wearing a watch to bed seems like a bad time, and perhaps even too geeky for me!) and I am sorely tempted to pick up one of these light-based alarm clocks, or one of these incredibly nifty USB X10 home automation systems. However, since right now the emphasis of this project is doing this on the cheap/free, none of those are real options.
This guy seems to posit that the best way to wake up is to be wakened up a little, and then, a lot. This mechanism apparently gently lifts you out of “deep sleep” into “light sleep”, which is (according to him) a more comfortable way to wake up. In that spirit, I’ve added some additional chunks to my Alarm-Clock applescript to wake up the user a little, with the playlist playing very softly at 25% volume, and then play again 15 minutes later, at three times louder or 75% volume. This is also a decent bare-bones example of how to write a subroutine in AppleScript:
***
global sound_volume
global day_of_week
–set user preferences here
set initial_sound_volume to 5
set delay_time_in_minutes to 15
set volume_multiplier to 15
–end user prefs
set day_of_week to (weekday of (current date)) as string
set delay_time_in_seconds to (delay_time_in_minutes * 60)
–with a timeout of one hour
with timeout of 3600 seconds
–first play the playlist softly…
set sound_volume to initial_sound_volume
wake_me_up()
–…wait for a while…
delay delay_time_in_seconds
–…then try again, louder.
tell application “iTunes”
stop
end tell
delay 3
set sound_volume to (sound_volume * volume_multiplier)
wake_me_up()
end timeout
on wake_me_up()
tell application “iTunes”
stop
set sound volume to sound_volume
try
play playlist day_of_week
on error
–do nothing
end try
end tell
return
end wake_me_up
***
~jeff