X
wikiHow is a “wiki,” similar to Wikipedia, which means that many of our articles are co-written by multiple authors. To create this article, volunteer authors worked to edit and improve it over time.
This article has been viewed 40,924 times.
Learn more...
Once you set one up, you can use a keyboard shortcut to turn on or off your WiFi on a Mac, easily.
Steps
Part 1
Part 1 of 2:
Creating the Action
-
1Open Terminal. Copy paste this in: networksetup -listnetworkserviceorder.
-
2Remember the number that shows the WiFi. Then, you can close Terminal and open Automator.Advertisement
-
3Choose a type for your document. Click on Quick Action and Choose.
-
4Search for run shell script in the search bar on the left. Double click on it.
-
5Make sure the top section is correct on the right: Workflow receives no input in any application.
-
6Copy and paste the following script into the section of “Run Shell Script,” substituting “X” with any number that you found the WiFi port to be earlier. The script is: networksetup -getairportpower enX | grep "On" && networksetup -setairportpower enX off || networksetup -setairportpower enX on.
-
7Click on Run in the top right corner. See if your WiFi turns off. You might need to wait a few seconds. If it works, click on the X and save the action, and name it something obvious like “WiFi Toggle.” Then, proceed to the next section.
Advertisement
Part 2
Part 2 of 2:
Creating the Keyboard Shortcut.
-
1Open System Preferences > Keyboard. At the top, click on Shortcuts.
-
2Click on Services. Scroll to the very bottom until you find the action that you just created.
-
3Click on the None to the right of the name. Then, click on Add Shortcut.
-
4Type in your shortcut. You might use Ctrl+⌥ Opt+⌘ Cmd+W. Control Option Command W). Make sure the shortcut is not a common shortcut.
-
5Test your shortcut. It should work!
Advertisement
Community Q&A
-
QuestionWhat OS system does this work on? It doesn't seem to be working on Mojave.Evan HuangCommunity AnswerThis should be working on Mojave. I tested it and it worked. Copy paste the code you entered into the section Run Shell Script.
Advertisement
About This Article
Advertisement