|
|
Determine whether screensaver is running
|
|
|
|
Grizzled Veteran
Join Date: Feb 2001
Location: Germany
Status:
Offline
|
|
hi everybody,
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?
any ideas?
|
|
|
|
|
|
|
|
|
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status:
Offline
|
|
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
|
|
|
|
|
|
|
|
|
Grizzled Veteran
Join Date: Feb 2001
Location: Germany
Status:
Offline
|
|
sysctl sounds fine, thanks for the tip. sounds feasable after having read some documentation.
|
|
|
|
|
|
|
|
|
Forum Regular
Join Date: Sep 2000
Location: UK
Status:
Offline
|
|
By the magic of class-dump (see fink), add this to your source somewhere:
@interface ScreenSaverController:NSObject <ScreenSaverControl>
{
NSConnection *_connection;
id _daemonProxy;
void *_reserved;
}
+ controller;
+ monitor;
+ daemonConnectionName;
+ daemonPath;
+ enginePath;
- init;
- (void)dealloc;
- (void)_connectionClosed:fp12;
- (BOOL)screenSaverIsRunning;
- (BOOL)screenSaverCanRun;
- (void)setScreenSaverCanRun BOOL)fp12;
- (void)screenSaverStartNow;
- (void)screenSaverStopNow;
- (void)restartForUser:fp12;
- (double)screenSaverTimeRemaining;
@end
Call this when you need to know:
[[ScreenSaverController controller] screenSaverIsRunning]
|
|
|
|
|
|
|
|
|
Grizzled Veteran
Join Date: Feb 2001
Location: Germany
Status:
Offline
|
|
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 ...
|
|
|
|
|
|
|
|
|
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status:
Offline
|
|
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
@interface ScreenSaverController:NSObject
+ controller;
- (BOOL)screenSaverIsRunning;
@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
- (double)screenSaverTimeRemaining;
- (void)restartForUser:fp16;
- (void)screenSaverStopNow;
- (void)screenSaverStartNow;
- (void)setScreenSaverCanRun char)fp19;
- (char)screenSaverCanRun;
- (char)screenSaverIsRunning;
@end</pre><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">
|
|
|
|
|
|
|
|
|
Grizzled Veteran
Join Date: Feb 2001
Location: Germany
Status:
Offline
|
|
thanks to both of you, guys!
i know why i love these forums and i know why i love cocoa! awesome!
|
|
|
|
|
|
|
|
|
Forum Regular
Join Date: Oct 2000
Location: Portland, OR USA
Status:
Offline
|
|
Is there a programmatic method for enabling/disabling the password protection feature of the screen saver?
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|