Add a Keyboard Shortcut to Toggle WiFi On and Off

Clicking the WiFi icon in OS X on and off when you're trying to troubleshoot Internet connectivity or AirPort issues can be annoying and disruptive to your workflow. Here's how to add a global keyboard shortcut to do it:

  • Copy the script from here and paste it into a new document in the AppleScript Editor. Save it as ToggleWifi (or whatever you want). Save it with Application as the file format.
  • Since there's no built in way to create a keyboard shortcut to launch an application in the Keyboard system preferences panel, first create a Service in Automator.
  • This post shows screenshots of the steps to create the Service. Open Automator, go to File->New and choose Service from the options that appear. Set "Service receives selected" to 'no input' and leave "in" set to 'any application'. Then search for the Launch Application action in the Actions menu on the left, and drag it to the open area that says "Drag actions or files here to build your workflow". Choose your AppleScript application from the Launch Application dropdown. Click compile then save the Service with a descriptive title, like "Toggle WiFi".
  • Open the Keyboard in System Preferences. Go to the Shorcuts tab, then go to Services and scroll down until you see the one you added in the last step. Make sure it's selected, then to the right of its name, click the grayscale "none" and a button to 'add shorcut' will appear.
  • Enter a unique keyboard shortcut. I chose control-option-command-9 so it wouldn't conflict with any other global or application shortcuts.

The above instructions should take effect immediately, so if your chosen keyboard shortcut doesn't work, try a different one. You might also need to modify a line of the AppleScript as this comment suggests. 

Popular posts from this blog

Verifying Doubles with ActionMailer in Rails 4

January #TMIL