Mac users can turn on/off Wifi using option available as part of the Menu bar.
![](https://i0.wp.com/www.blogmines.com/wp-content/uploads/2021/06/image.png?resize=352%2C119&ssl=1)
Add quick action in Automator app
Launch Automator app on your mac and choose Quick Action.
![](https://i0.wp.com/www.blogmines.com/wp-content/uploads/2021/06/image-1.png?resize=432%2C313&ssl=1)
Choose action as “Run Shell Script” then set Workflow receives to “no input” and set it to run for for any application and select an image for your action.
![](https://i0.wp.com/www.blogmines.com/wp-content/uploads/2021/06/image-2.png?resize=1024%2C382&ssl=1)
Then under the run script window add the following script.
set_wifi_on_or_off() { networksetup -getairportpower en${n} | grep ": ${1}"; if test $? -eq 0; then echo WiFi interface found: en${n}; eval "networksetup -setairportpower en${n} ${2}" return 0; fi return 1; } for n in $(seq 0 10); do if set_wifi_on_or_off "On" "off"; then break; fi; if set_wifi_on_or_off "Off" "on"; then break; fi; done
![](https://i0.wp.com/www.blogmines.com/wp-content/uploads/2021/06/image-3.png?resize=508%2C431&ssl=1)
You can test the above script using “Run” option and check if Wifi settings turned On or Off based on the current state. Save this quick action by providing a name as “Wifi”
Assign a keyboard shortcut for quick action
Launch Keyboard preferences using System preferences and navigate to Shortcuts tab.
![](https://i0.wp.com/www.blogmines.com/wp-content/uploads/2021/06/image-4.png?resize=470%2C424&ssl=1)
The newly added Wifi quick action will be available under Services. Now assign a keyboard shortcut for this action.
![](https://i0.wp.com/www.blogmines.com/wp-content/uploads/2021/06/image-5.png?resize=512%2C155&ssl=1)
Note :- Make sure to select 3 letters or more keyboard combination for your shortcut. Sometimes other apps might be using the same set of key combination and this would prevent launching the Automator action.
Leave a Reply