Skip to content

Instantly share code, notes, and snippets.

@kevin-funderburg
Created May 9, 2019 17:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevin-funderburg/ff532cafb8cec46cd035cf6a5a1ff333 to your computer and use it in GitHub Desktop.
Save kevin-funderburg/ff532cafb8cec46cd035cf6a5a1ff333 to your computer and use it in GitHub Desktop.
Wi-fi toggle for macs.
set device to do shell script "networksetup -listallhardwareports | awk '$3==\"Wi-Fi\" {getline;print}' | awk '{print $2}'"
set power to do shell script "networksetup -getairportpower " & device & " | awk '{print $4}'"
if power is equal to "on" then
set power to "off"
else
set power to "on"
end if
do shell script ("networksetup -setairportpower " & device & " " & power)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment