Tuesday, February 9, 2010

#1 2005-10-26 10:05:12 am

Kim Hunter
Member
From: Australia
Registered: 2004-09-18
Posts: 213

iTunes Alarm Clock

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 "

Applescript:

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

Applescript:

#!/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"

Applescript:

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


Filed under: iTunes

Offline

 

Board footer

Powered by FluxBB

[ Generated in 0.154 seconds, 10 queries executed ]

RSS (new topics) RSS (active topics)