Hi, I like to fall asleep to itunes and wake up to it also, I have made a couple of scripts for this purpose. The wakup script is simple enough, and it is launched at login in the usual way. However I would like to make it able to run after the mac wakes up too. Also, the sleep script has options to sleep or shut down after a certain song is played. However sometime when it gets to that song and tries to shut down the script won’t quit and stops the stystem from shutting down. Subsequently it will not wake me up in the morning.
here are the scripts, can anyone suggest a better way to do achieve what I want to do?
wakeup script (launched at login):
tell application "iTunes"
try
set current EQ preset to EQ preset "Flat"
end try
try
play playlist "***Wakeup"
on error
play some playlist
end try
end tell
sleep script (launched manually):
property sleep_var : ""
property time_var : ""
property prop_var : ""
property action_var : ""
display dialog "Action?" buttons {"Cancel", "Sleep", "Shut Down"} default button 3 giving up after 21
set action_var to button returned of the result
if action_var is "" then set action_var to "Shutdown"
tell application "iTunes"
try
set endtrack to name of selection as string
tell me
display dialog "Your Computer will " & action_var & "after song " & "'" & endtrack & "'" & " is played" giving up after 5
end tell
try
repeat until name of current track = endtrack
delay 2
end repeat
on error
tell me
display dialog "iTunes is not playing" buttons "Cancel" default button 1 giving up after 5 with icon 2
my quitout()
end tell
end try
on error
tell me
display dialog "No trak is selected" buttons "Cancel" default button 1 giving up after 5 with icon 2
my quitout()
end tell
end try
my checktime()
end tell
on showsong()
display dialog "Your Computer will " & action_var & "after song " & "'" & endtrack & "'" & "is played" giving up after 2
end showsong
my checktime()
on checktime()
tell application "iTunes"
delay 2
if player state is not playing then my action_time()
try
set time_var to (time of current track) as string
set min_utes to (first word of time_var) * 60
set delay_time to min_utes + (second word of time_var)
set playpoint to player position + 1
set time_var to delay_time - playpoint
end try
end tell
delay (time_var)
try
tell application "iTunes"
stop
end tell
on error
my action_time
end try
my action_time()
end checktime
on action_time()
if action_var is "Shut Down" then tell application "Finder" to shut down
if action_var is "Sleep" then tell application "Finder" to sleep
my quitout
end action_time
on quitout()
tell me to quit
end quitout
To summarise what I want:
¢ to choose a track in an iTunes playlist, and have the mac either shutdown, or sleep once that track has finished playing
¢ if sleep was the option above, I want a certain iTunes playlist to be played once the machine wakes up
the problem I have with the current scripts is I don’t know how to activate it after wakeup, and the script (saved as an app) seems to freeze up and stop the mac from shutting down.
any help mucho appreciated.
thanks,
arum