views:

118

answers:

1

Is there a way to trigger an action when the Mac OS X screensaver activates or when it goes to sleep (preferably using cocoa)?

+4  A: 

You can register for various distributed notifications—on 10.6, I'm seeing com.apple.screenIsLocked/screenIsUnlocked and com.apple.screensaver.didstart/willstop/didstop. (Older versions of Mac OS X may not have all of these notifications.) You can observe the notifications as they occur with Notification Watcher.

Also see this answer.

Nicholas Riley