views:

220

answers:

2

Hi,

I am looking for a way to execute my app (it's a background task) at times, where the machine is "idle". A good incident would be when the screensaver launches. I already read the manual auf launchd and already use a LaunchAgent to lauch my app at certain intervals, but I found nothing that might help me launching my app when the screensaver is active.

Is there any possibility to do that?

Thanks in advance!

Josh

+1  A: 

Have another process that runs in the background and listens for distributed notifications named com.apple.screenIsLocked and com.apple.screenIsUnlocked. (That's for Snow Leopard. Leopard used different notification names. Use Notification Watcher and experimentation to find out what they are.) When one of those notifications comes in, launch or nicely-quit* your real app, as appropriate.

*You'll want to use an Apple Event for this.

Peter Hosey
A: 

You can use ScriptSaver by Matt Swann. This is a Mac OS X screensaver which can run AppleScripts when it activates and deactivates.

http://swannman.wordpress.com/projects/scriptsaver/

portenkirchner