Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to be able to hide and show the Wi-Fi menu item from the Terminal. Can I do this with the defaults command?

I've narrowed it down to It looks like this:

    "NSWindow Frame NoTimeLeft" = "471 437 475 163 0 0 1366 746 ";
    "__NSEnableTSMDocumentWindowLevel" = 1;
    menuExtras =     (
        "/System/Library/CoreServices/Menu Extras/Script",
        "/System/Library/CoreServices/Menu Extras/",
        "/System/Library/CoreServices/Menu Extras/",
        "/System/Library/CoreServices/Menu Extras/",
        "/System/Library/CoreServices/Menu Extras/"

Preferences Screenshot

share|improve this question
up vote 2 down vote accepted

A big difficulty here is that the menuExtras key in is an array that's reordered when you drag your Menu Extras around in the menu bar (and add and remove them).

In your case cited above, the Wi-Fi Menu Extra is the second item (which is array index 1 because these arrays are zero-indexed like C arrays), so you could remove it with PlistBuddy, which isn't in your $PATH because it's hidden in /usr/libexec. You have to use PlistBuddy because the defaults command doesn't have syntax for specifying an array index. Then kill SystemUIServer to get it to reload:

/usr/libexec/PlistBuddy -c 'Delete :menuExtras:1' ~/Library/Preferences/
killall SystemUIServer

To add it back in, do something like this:

/usr/libexec/PlistBuddy -c 'Add :menuExtras:1 string "/System/Library/CoreServices/Menu Extras/"' ~/Library/Preferences/
killall SystemUIServer

Note that this will break if you ever remove or add Menu Extras such that the Wi-Fi Menu Extra is not the second Menu Extra from the left in your menu bar. With a little more scripting work you could walk the menuExtras array looking for the AirPort (Wi-Fi) menu extra, note its index, then feed that into your PlistBuddy command.

share|improve this answer
This does edit correctly but airport is still there after killing SystemUIserver. It just moves to the left. This is odd. – ggustafsson Mar 8 '12 at 15:37
@ggustafsson Huh, it's working for me on Mac OS X Lion v10.7.3. You didn't do both the Delete and Add at the same time, did you? You're only supposed to do the Delete when you want to hide it, and the Add when you want to show it. – Spiff Mar 8 '12 at 22:17
It works half of the time. I can't find a pattern here. I'll try it out for a while and see what happens. There's a typo btw, it's should be "killall SystemUIServer" in the add box. – ggustafsson Mar 9 '12 at 4:38
Thanks @ggustafsson. I fixed the typo. – Spiff Mar 9 '12 at 10:30

I wrote a script that cycles through the menuExtras and deletes WiFi. If you know the name of the menu item in Menu Extras you could easily modify it for any other menu item. I did not put a kill SystemUIServer at the end of the script. If you want instantaneous satisfaction you could add that as the last line in the script. A logout/login should probably work as well. I am sure the sed lines could be cleaned up a bit, as well. This was tested on 10.8.4, but there is no reason it should not work going back at least to 10.6


# Removes the Wifi menu from the menubar.
# This setting is set on a per-user basis, so needs to be run as the user
# Will require a logout. A 'kill SystemUIServer' might work?


menutemp=$(defaults read menuExtras)
menutemp2=$(echo $menutemp | sed 's/( //')
menutemp3=$(echo $menutemp2 | sed 's/ )//')

read -a menuitems <<< "$menutemp3"

for (( i = 0 ; i < ${#menuitems[@]} ; i++ ))
    if [ "${menuitems[$i]}" = '"/System/Library/CoreServices/Menu Extras/"' ]
        /usr/libexec/PlistBuddy -c "Delete :menuExtras:$i" ~/Library/Preferences/
share|improve this answer

A different strategy for hiding the icons for all other users. Go to /System/Library/CoreServices/Menu Extras/, you will see several files that end with menu. Click on the menu you want to hide. Once the menu is selected, use the keyboard and hold Command + I for the Info menu.

Under Sharing & Permissions:, Click the Plus box (you may need to unlock this area first) and add you user name to the list, giving yourself Read & Write Privileges. Then change the privileges on Everyone to No Access. Leave System and Wheel alone. Close the window. Log-out and log-in as another user. You can hide many menus.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .