i recently set my mini as a wake up alarm clock this is what i did.
in energy saver i set a wake up schedule to wake the mac from sleep a little before the desired time.
there is a flag file needed so that the script wont run all the time you will have to set it at night.
and the flag file allows for ssh access to stop itunes from playing when the script next runs.
added this line to my user crontab via command " crontab -e "
4 8 * * 1-5 sh ~/scripts/alarm
this means run the script: Mon to Fri at 8:04am
to save calling other scripts and to keep it simple i just put the apple script into a bash script.
here is the shell script
#!/bin/bash
FLAG=`cat ~/.alarm`
if [ "$FLAG" = "1" ]
then
osascript -e 'set volume 7
tell application "iTunes"
set sound volume to 100
tell playlist "Wakeup" to play
end tell'
# sleep 30 ;
# osascript -e 'set volume 5'; #wait 30 sec and turn volume down a little
#set flagfile so that it doesn't go off every day unless you set it with the script before
# echo 0 > ~/.alarm ;
fi
and here is the applescript to set the alarm at nigth if you decide to uncomment the “echo 0> ~/.alarm”
set flag to do shell script "cat ~/.alarm"
if flag is equal to "1" then
set STR to "Already Set, click set alarm"
else
set STR to "Alarm is NOT set"
end if
display dialog STR buttons {"Set Alarm", "No"} default button 1
if the button returned of the result is "No" then
do shell script " echo '0' > ~/.alarm"
else
do shell script " echo '1' > ~/.alarm"
end if