Macos – Turn ON/OFF Wifi in OS X Utility

macoswireless-networking

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.

Best Answer

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

#!/bin/bash

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.