问题描述
我正在寻找一种方法来执行我的应用程序(这是一项后台任务),有时机器是空闲的。屏幕保护程序启动时是一个好事件。我已经阅读了已启动的手册auf,并且已经使用LaunchAgent在一定间隔下对我的应用程序进行放行,但是在屏幕保护程序处于活动状态时,我发现没有任何东西可以帮助我启动我的应用程序。
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.
是否有可能这样做?
预先感谢!
乔什
推荐答案
对于Snow Leopard,screenIsLocked和screenIsUnlocked通知不再可用。我成功使用的是这些:
For Snow Leopard the screenIsLocked and screenIsUnlocked notifications aren't available anymore. What I've used successfully are these:
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(locked:) name:NSWorkspaceScreensDidSleepNotification object:nil];
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(unlocked:) name:NSWorkspaceScreensDidWakeNotification object:nil];
这篇关于LaunchAgent-是否有类似RunAtScreenSaver的东西?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!