Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'A script to listen to RealOne radio then sleep' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
A script to listen to RealOne radio then sleep
Authored by: joshewah on Jan 19, '05 10:36:08AM

I do something similar at night sometimes but I use the iWannaSleep program http://www.sb-software.de/en/

It automatically can tell itunes to stop playing at night, but you can give it any applescript. So you can put one similar to the osascript commands you used, then set the time in the program. It will run the script when the timer goes to 0 so it doesn't matter what stream it is you are playing.



[ Reply to This | # ]
A script to listen to RealOne radio then sleep
Authored by: macg4dave on Jan 20, '05 03:26:40PM

I made this one for you that's a bit longer but you can quit a application as well as shutdown just copy this into script edit and save it as a application

---
property timefromnow_time : date
on run

set theresult to display dialog "Type path of program you want to open" buttons {"Cancel", "Ok"} default answer "/Applications/iTunes.app"
log theresult
set button to button returned of theresult
set program to text returned of theresult

if button is "Cancel" then

else if button is "Ok" then
display dialog "Do you want to Quit, Restart or Shutdown?" buttons {"Quit", "Restart", "Shutdown"}
set secbutton to button returned of the result
if secbutton is "Quit" then
set quitresponse to display dialog "Number of minutes until Quit?" default answer "60"
set timer to (text returned of the quitresponse) as number
set timefromnow_time to (current date) + (timer * minutes)
display dialog "The program will quit in: " & timefromnow_time as string
do shell script "open " & program & " > /dev/null 2>&1 & echo $!"
set pid to the result
do shell script "sleep " & (timer * minutes) as string
do shell script "kill " & (pid + 2) as string

else if secbutton is "Shutdown" then
set shutdownresponse to display dialog "Number of minutes until Shutdown?" default answer "60"
set timer to (text returned of the shutdownresponse) as number
set timefromnow_time to (current date) + (timer * minutes)
display dialog "This computer will shutdown at: " & timefromnow_time as string
do shell script "open " & program & " > /dev/null 2>&1 & echo $!"
do shell script "shutdown -h +" & timer as string & " ZzZ shutdown"

else if secbutton is "Restart" then
set restartresponse to display dialog "Number of minutes until Restart?" default answer "60"
set timer to (text returned of the restartresponse) as number
set timefromnow_time to (current date) + (timer * minutes)
display dialog "This computer will Restart at: " & timefromnow_time as string
do shell script "open " & program & " > /dev/null 2>&1 & echo $!"
do shell script "shutdown -r +" & timer as string & " ZzZ restart"

end if
end if
end run
---



[ Reply to This | # ]