Control AirPort from the keyboard
If you use the Airport menu item primarily to turn Airport on and off, you can save some space on the menu bar by getting rid of the Airport icon and enabling or disabling wireless networking from the keyboard (or mouse) instead.
To start with, you need to find out the device name of your AirPort network interface. To do so, open System Profiler (Apple -> About This Mac, More Info). In the lefthand pane, select the Network section. In the upper right pane, you’ll see a list of your network devices. Find the one named AirPort then find its entry in the BSD Device Name column. For the sake of explanation, let’s say it’s
The key here is a command-line utility,
networksetup. It can perform all kinds of network related actions, but the one we’re interested in is turning AirPort power on or off; for that, you use the
-setairportpower switch. So, to turn AirPort power off, you’d enter the command
networksetup -setairportpower en1 off. To turn it back on, you’d use the same command, replacing
There are a few ways to make this shell command accessible from within the OS X GUI. One way is to create an application. To do so, open AppleScript Editor ( /Applications/Utilities/) and enter:
do shell script "networksetup -setairportpower en1 on". Select File > Save As…, supply a name (AirPort On, for example), select Application as file format, and store it in your Applications or Utilities folder. With the script still open, change the script’s
off, select File > Save As…, and give it a name (AirPort Off). You can now put these applications in the Dock, Finder toolbar, or sidebar, or launch them using Spotlight or whatever other method you choose.
Alternatively, you can implement the shell command as an Automator service. Open Automator and select Service from the list of templates. In the bar near the top of the editing pane, configure the service to receive No Input in Any Application. Open the Utilities section in the Library on the left, then add the Run Shell Script action to the editing pane by dragging or double-clicking it. Replace whatever is in the action’s text area with
networksetup -setairportpower en1 on. Select File > Save as… and name the service AirPort On. Change the shell script to turn power off, and select Save As… again, this time naming it AirPort Off. You can now assign keyboard shortcuts to your services in the System Preferences Keyboard pane: go to the Keyboard Shortcuts tab and edit their entries in the Services list.
With your new application or service at hand, you can get rid of the menu bar Airport icon: Go to the Network pane in System Preferences, select the Airport interface in your current location and uncheck the Show Airport Status in Menu Bar box.