Skip to content

Instantly share code, notes, and snippets.

@theotherian
Last active January 15, 2024 00:50
Show Gist options
  • Save theotherian/5954592 to your computer and use it in GitHub Desktop.
Save theotherian/5954592 to your computer and use it in GitHub Desktop.
An AppleScript for toggling wifi on and off
A script for turning wifi on and off on a Mac
set status to do shell script "networksetup -getairportpower en1"
if status ends with "On" then
do shell script "networksetup -setairportpower en1 off"
else
do shell script "networksetup -setairportpower en1 on"
end if
@podfeet
Copy link

podfeet commented Aug 31, 2020

Sweet. Just what I needed to add to my Automator app.

@theotherian
Copy link
Author

@NosillaCast nice; glad it helped 👍

@pradeepb28
Copy link

it doesn't seems to be working in monterey

error "en1 is not a Wi-Fi interface.
** Error: Error obtaining wireless information." number 10

@rocket-star
Copy link

rocket-star commented Apr 13, 2022

it doesn't seems to be working in monterey

error "en1 is not a Wi-Fi interface.
** Error: Error obtaining wireless information." number 10

@pradeepb28 replace en1 by en0 and try again should work

@pradeepb28
Copy link

Thanks, it works with en0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment