A feature I've been waiting for, but it took procrastinating for a big test and a project to finally get me to sit down and figure it out.
This makes use of AppleScript and Cron. It also assumes you have a playlist that opens by default in iTunes.
First, open Script Editor and type this stuff in. Note that when I say << and >> in my code, I mean the character generated by option-\ and option-shift-\
Compile the script as an Application and save it somewhere under a name you can remember. I have mine saved in /Applications under Play, but you can put it anywhere you'd like. Test it, and make sure it starts iTunes playing when you double click on it.
Apple provides a command line utility called "open" that makes the argument you pass it behave as if you've double clicked on it. Fire up a terminal and try
open /Applications/Play
substituting where you put it and what you named. If it works, then you're a little closer.
The next part is good stuff...we use the Unix utility cron to automatically execute it when ever you want to wake up.
A cronjob is specified thusly by saying crontab -e from the command line:
Minute Hour DayOfMonth MonthOfYear DayOfWeek [Command]
You can specify valid numeric values for each of the options, or stick in a * for it to run [command] every time a valid option comes up.
So if you wanted to execute something every Monday and Thursday at 1:25 PM, you'd say:
25 13 * * Mon,Thu [command]
Or the first and fifteenth of January and June at 2:38 pm, you'd say:
38 15 1,15 1,6 * [command]
Or in our case, at 8:15 am every weekday morning, you'd say:
15 08 * * Mon,Tue,Wed,Thu,Fri /usr/bin/open /Applications/Play
Cron opens in the vi editor by default, so after you've made the entry you want (and you can make as many as you want) you should hit the escape button, then :wq to exit vi.
You may want to put a few testing entries in there to make sure you're working right, but other than that, you should be set! Good luck, and post here to let me know how it goes!
NOTE: Cron wants the last line in the file to be a new line, so make sure you hit return a couple of times after the last crontab entry in your file.
Thanks go out to the good folks at www.applescriptcentral.com, especially <a href="http://www.barzeski.com">erik</a> for helping me get this working.
This makes use of AppleScript and Cron. It also assumes you have a playlist that opens by default in iTunes.
First, open Script Editor and type this stuff in. Note that when I say << and >> in my code, I mean the character generated by option-\ and option-shift-\
Code:
tell application "iTunes"
-- I have it skip to the next song, in case
-- we stopped in the middle of playing something.
<< event hookNext>>
-- this next part sets a nice volume for waking up to.
-- omit if you'd like
set counter to 20
repeat until counter = 0
<< event aevtvol->>
set counter to counter - 1
end repeat
set counter to 10
repeat until counter = 0
<< event aevtvol+>>
set counter to counter - 1
end repeat
-- this next line actually starts playing iTunes
<< event hookPlay>>
end tell
Compile the script as an Application and save it somewhere under a name you can remember. I have mine saved in /Applications under Play, but you can put it anywhere you'd like. Test it, and make sure it starts iTunes playing when you double click on it.
Apple provides a command line utility called "open" that makes the argument you pass it behave as if you've double clicked on it. Fire up a terminal and try
open /Applications/Play
substituting where you put it and what you named. If it works, then you're a little closer.
The next part is good stuff...we use the Unix utility cron to automatically execute it when ever you want to wake up.
A cronjob is specified thusly by saying crontab -e from the command line:
Minute Hour DayOfMonth MonthOfYear DayOfWeek [Command]
You can specify valid numeric values for each of the options, or stick in a * for it to run [command] every time a valid option comes up.
So if you wanted to execute something every Monday and Thursday at 1:25 PM, you'd say:
25 13 * * Mon,Thu [command]
Or the first and fifteenth of January and June at 2:38 pm, you'd say:
38 15 1,15 1,6 * [command]
Or in our case, at 8:15 am every weekday morning, you'd say:
15 08 * * Mon,Tue,Wed,Thu,Fri /usr/bin/open /Applications/Play
Cron opens in the vi editor by default, so after you've made the entry you want (and you can make as many as you want) you should hit the escape button, then :wq to exit vi.
You may want to put a few testing entries in there to make sure you're working right, but other than that, you should be set! Good luck, and post here to let me know how it goes!
NOTE: Cron wants the last line in the file to be a new line, so make sure you hit return a couple of times after the last crontab entry in your file.
Thanks go out to the good folks at www.applescriptcentral.com, especially <a href="http://www.barzeski.com">erik</a> for helping me get this working.