View Single Post
Old 05-09-2005, 09:35 PM   #10
rgreen103
Newbie
 
Join Date: Apr 2005
Posts: 19
Quote: Originally Posted by Bugbyte
I checked into doing this via Applescript. Here's a response I got:

"Unfortunately, I don't think you can do this from AppleScript. However, there's still hope.
The Carbon framework enables you to implement a callback to catch and even halt sleep - which would then let you perform your shut down.
The Cocoa frameworks (AppKit's NSWorkspace class in particular) has a notification, NSWorkspaceWillSleepNotification, that can cause sleep to be suspended for up to 30 seconds. You may be able to begin a shut down during those 30 seconds."

I will look into the framework and see what else I can find out. If a small app can be written to do this, we only need run it on startup.

[Edit] Found this: "NSWorkspace now provides sleep notifications. NSWorkspaceWillSleepNotification and NSWorkspaceDidWakeNotification will be sent before the machine sleeps and after the machine wakes, respectively. An observer of NSWorkspaceWillSleepNotification can delay sleep for up to 30 seconds within the handling of the notification."

from here: http://developer.apple.com/releaseno...lderNotes.html

[Double Edit] Crap! I misspelled Mini in the thread title and it shows as "Mine". Changing it didn't fix it. Kandyman, can you fix it?

I tried playing with the NSWorkspaceWillSleepNotification and what would happen was the machine would sleep before the notification was triggered. Then after I brought it out of sleep the code would be executed. After digging around on lists.apple.com I found out that there is 2 types of sleep. One is idle sleep and this can be interrupted programatically and the other is a forced sleep (power button or menu initiated) which can not be interrrupted. Here is some info http://lists.apple.com/archives/darw.../msg00041.html

Last edited by rgreen103; 05-11-2005 at 06:23 AM.
rgreen103 is offline   Reply With Quote