Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Darkroom

Guest
Original poster
Dec 15, 2006
2,445
0
Montréal, Canada
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

Code:
  //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:

Code:
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

Moderator emeritus
Jun 15, 2000
7,958
7
Probably the best way is to read the "menuExtras" key from the plist at ~/Library/Preferences/com.apple.systemuiserver.plist
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.