PDA

View Full Version : Poll SystemUIServer For Active Plug-Ins?




Darkroom
Jan 15, 2009, 06:23 PM
As far as i know, menu bar extras (like Volume, Date & Time, Time Machine, etc.) are plug-ins of the SystemUIServer...

I can poll for open applications with something like the following


//Poll Processes
NSWorkspace *ws = [NSWorkspace sharedWorkspace];
NSArray *runningAppDictionaries = [ws launchedApplications];
NSDictionary *aDictionary;

for (aDictionary in runningAppDictionaries)
{
if ([[aDictionary valueForKey:@"NSApplicationBundleIdentifier"]
isEqualToString:@"com.apple.TextEdit"])
{
NSLog(@"TextEdit Is Active");
return;
break;
}
}

NSLog(@"TextEdit Is Not Active");


Now i have the identifier of the Volume menu bar extra:


com.apple.menuextra.volume


I guess i could poll to see if the SystemUIServer is active because it shows up in Activity Monitor, but how can i go one level down and ask the SystemUIServer to list it's active Plug-Ins (menu bar extras)?

Is it even possible? I guess it has to be possible since they accept mouse events for removing and reorganizing, so they must be programatically accessible...



kainjow
Jan 20, 2009, 03:25 PM
Probably the best way is to read the "menuExtras" key from the plist at ~/Library/Preferences/com.apple.systemuiserver.plist

Darkroom
Jan 20, 2009, 03:49 PM
oh that's perfect... thanks...

:)