Poll SystemUIServer For Active Plug-Ins?

Discussion in 'Mac Programming' started by Darkroom, Jan 15, 2009.

  1. Darkroom Guest

    Darkroom

    Joined:
    Dec 15, 2006
    Location:
    Montréal, Canada
    #1
    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...
     
  2. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #2
    Probably the best way is to read the "menuExtras" key from the plist at ~/Library/Preferences/com.apple.systemuiserver.plist
     
  3. Darkroom thread starter Guest

    Darkroom

    Joined:
    Dec 15, 2006
    Location:
    Montréal, Canada

Share This Page