Hi everyone,
first of all thank you all guys for this very useful forum. I have learned a lot from the discussions here.
So now for my problem:
I have written a small AppleScript, which sends my iMac to sleep. But before it does so, a dialog appears, which allows the User to stop this action (in case I am still working at night I do not want my iMac to go to sleep, of course). The script also checks, whether EyeTV is playing or recording
tell application "EyeTV"
if (is_saving_clip_as_recording or is_compacting or is_exporting or is_recording or playing or server mode) then
return
end if
end tell
delay 1
with timeout of 120 seconds
display dialog "This Mac is going to sleep in a minute. Is that OK for you?" with icon 0 buttons {"No!"} giving up after 60 default button "No!"
set theresults to the result
if gave up of theresults is true then
tell application "System Events" to sleep
end if
end timeout
Under Snow Leopard I saved the AppleScript as an application (Sleep.app) and set up a cron job to run it every day at 1 am by using the command:
open /Applications/Sleep.app
While this all worked perfectly under Snow Leopard, it does not work under Lion anymore. Now I get a dialog, which says
.
However, running the command “open /Applications/Sleep.app” directly from Terminal works fine.
I have also tried to set up a plist for launchd (with Lingon). Every time launchd tries to launch the application I get the following error in the log file
I have also tried to run the applescript via the osascript command. And I have tried all the tricks described here. Same problem all the time! Again, everything works fine, when I do the same commands directly in the terminal, but I can’t run the script via cron or launchd under Lion.
I hope you guys can help me out with this issue, since I couldn’t find any solutions for this problem by searching the web, and I think that I am not the only one with this problem.
MacPingu