What Menu Items?
Long story short, after trying to upgrade to macOS Big Suck Sur 11.1 (but I'm not still bitter, honest), I was left with a computer that no longer booted past the loading screen—though Safe Mode worked for some reason. I thought perhaps downgrading to 11.0.1 might restore things to working order, but after inadvertently separating my Data volume from its System sibling, I decided maybe it was time for some long overdue spring cleaning anyway. Well, that paired with noticing files from February of 2012 that were still lingering after many migrations over the better part of a decade.
After reinstalling applications and copying over associated preference plists, there were some applications whose menu bar icons were missing. There is some discussion online of what appeared to be the same issue, but none of the suggested remedies had any effect.
Back before Apple offered a public API for menu items, developers used the private NSMenuExtra API. SystemUIServer was (and apparently still is, in some cases) responsible for displaying the menu items in the menu bar, so I thought perhaps ~/Library/Preferences/com.apple.systemuiserver.plist
was a good place to start. Unfortunately, the only menu item mentioned there was for Time Machine. Surprising that the other Apple-approved menu items are no longer technically "menu extras." But I digress.
I decided it might be helpful to identify which preference plists were updated when I changed the visibility setting for a missing menu item. Fortunately, HammerSpoon has preference window that is both accessible by means other than the menu item and offers the ability to toggle menu item visibility in preferences.
Sorting by "Date Modified," it turns out that the visibility and "preferred position" of an application's menu item is stored in the application's preference plist. Shocker:
<plist version="1.0">
<dict>
<key>NSStatusItem Preferred Position Item-0</key>
<real>1018</real>
<key>NSStatusItem Visible Item-0</key>
<true/>
</dict>
</plist>
I tried changing the NSStatusItem Visible
key to <true/>
and relaunching the application, but it appears that the property is cached such that it is reset when the application launches.
While I didn't delve into which process manages the NSStatusItem
menu items (I can, however, confirm that it definitely isn't SystemUIServer), the solution that I found was to edit the plist and leave the application as-is (either running or closed). After rebooting, the missing menu items were back!
Quick aside: If you are not familiar with editing plists, they tend to be
stored in a binary format. They can be converted to XML using the plutil
command in Terminal so they can be edited with
a regular text editor.
% plutil -convert xml1 /Users/me/Library/Preferences/com.protonmail.bridge.plist
For example, the above command
will convert the binary plist file com.protonmail.bridge.plist
into a normal XML file. No need to
convert it back to a binary plist, as that will happen when the file is
updated by the system (though using binary1
in place of xml1
will perform the opposite conversion).