Determine whether screensaver is running
i think the topic says it all... is there a way?
i thought about doing a "ps" from an nstask and see whether "/System/Library/Frameworks/ScreenSaver.framework/Versions/A/Resources/ScreenSaverEngine.app" was among the running processes but i figured this was not very elegant -- is there a better way?
I think you're probably going to have to do that, yeah, but you should probably use Carbon's Process Manager or sysctl to determine if it's running or not. I think that's a nicer solution than running ps from an NSTask, personally :)
sysctl sounds fine, thanks for the tip. sounds feasable after having read some documentation. :)
By the magic of class-dump (see fink), add this to your source somewhere:
@interface ScreenSaverController:NSObject <ScreenSaverControl>
Call this when you need to know:
[[ScreenSaverController controller] screenSaverIsRunning]
woohoo, sounds great!
but... i'm sorry, i've never used any class-dumps in my own source code before... it complains it cannot find the protocol declaraction for "screensavercontrol" -- i tried linking against the screensaver framework, the only idea i've had, but... no success. a recursive grep for the declaration in /system/library/frameworks/screensaver.framework didn't turn up anything, either.
could you help me once again with my stupidity, please?
...i guess i'll never be a good programmer :( ...
You haven't declared the ScreenSaverControl protocol in any headers, but referred to it in the declaration for ScreenSaverController, so the compiler is getting confused. You don't have to fully declare classes anyway, so just to keep the compiler happy you could do:
</font><blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">// hack definition for private class
@end</pre><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">Or you could just declare the ScreenSaverControl category, which is:
</font><blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">@protocol ScreenSaverControl
@end</pre><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">
thanks to both of you, guys!
i know why i love these forums and i know why i love cocoa! awesome!
Is there a programmatic method for enabling/disabling the password protection feature of the screen saver?
|All times are GMT -4. The time now is 07:56 AM.||
Copyright © 2005-2007 MacNN. All rights reserved.
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2015, vBulletin Solutions, Inc.