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'm looking for a simple utility that I could configure to a hotkey which would allow me to toggle ON/OFF my Mac's Wi-Fi.

share|improve this question
Maybe not the easiest but this seems to work:… – Matteo Sep 11 '11 at 16:02

You could assign a shortcut to a script like this using an app like FastScripts or Alfred:


device="$(networksetup -listallhardwareports |
grep -E '(Wi-Fi|AirPort)' -A 1 | grep -o "en.")"
[[ "$(networksetup -getairportpower $device)" == *On ]] && val=off || val=on
networksetup -setairportpower $device $val

If you use Alfred and have the Powerpack, there's an extension called Toggle wifi on/off that basically just runs a shell script like the one above.

share|improve this answer

We built Airtoggle exactly for this. It's great for people who don't want to use scripts etc.

share|improve this answer
up vote 1 down vote accepted

Something like this worked for me.

So I made the following alias commands for use within Terminal on the command line interface.

alias adhoc='networksetup -setairportnetwork en1 <adhoc SSID>'
alias wifi='networksetup -setairportnetwork en1 <my wifi SSID> <WPA2 password>'
share|improve this answer
I used a similar approach to cycle the Wi-Fi. Put it in an Automator workflow > Run shell script. Save as Application or Service (to use a hotkey): networksetup -setairportpower en0 off; networksetup -setairportpower en0 on – brandonjp Sep 23 '12 at 17:02

Although there seems to be no reliable way of turning AirPort on or off directly via the shell, it is possible to get around that by manipulating OS X's Locations with the scselect command.

First, create a new location called AirPort-Off in the Network preferences pane. With this new location selected, select Network Port Configurations under the Show pop-up menu, and deselect AirPort. Then select your previous location, which for most people would probably be Automatic.

Now, you can turn AirPort off by running scselect AirPort-Off and back on by running the last command, replacing AirPort-Off with the name of your normal location name. To assign a hot key to the command using a utility like Butler, create a simple AppleScript containing this one line:

do shell script "/usr/sbin/scselect AirPort-Off"

Then have Butler (or your app of choice) run that APpleScript. (With Butler, running a shell script containing only the bare command doesn't seem to work.)

share|improve this answer
networksetup -setairportpower en0 off and networksetup -setairportpower en0 on works. – ggustafsson Dec 11 '12 at 13:40

You must log in to answer this question.

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