How to quick switch OSX proxy on/off?
Solution 1:
Have you tried using the Locations feature?
- Go to System Preferences > Network,
- Click on the "Location" dropdown menu,
- Choose "Edit Locations",
- Click on the add button and give the location a name. I would suggest you give it a name that's related to the proxy,
- Now that you've setup a new location, go through the networking configuration, ensuring you set the relevant proxy setting under the "Proxies" tab, which can be found under the Ethernet/WiFi adapter settings > Advanced.
Repeat steps 1-5 for each proxy.
Once you've finished, you can quickly switch between each proxy by clicking on the Apple icon (located at the top left of your screen) and going to "Location". Once the Location menu expands, you should see all your different locations, which have the relevant proxy settings within them. Clicking on the locations will change the proxy settings your Mac uses.
Solution 2:
I just found ControlPlane, lasted version is 1.6.5
.
It's a great application that can take certain actions upon certain context change events, e.g. context change event can be connected to a specified WiFi network (per SSID), and action can be switch locations, hence uses location specific proxies.
And here is a step-by-step guide, which explains how to achieve this using ControlPlane.
Solution 3:
Apple Script Solution
Copy the code into the file ~/Library/Scripts/proxytoggle.applescript
set socksStatus to do shell script "networksetup -getsocksfirewallproxy Wi-fi | grep Enabled"
if (offset of "Yes" in socksStatus) = 0 then
do shell script "networksetup -setsocksfirewallproxystate Wi-fi On"
display notification "Proxy Enabled !"
else
do shell script "networksetup -setsocksfirewallproxystate Wi-fi Off"
display notification "Socks disabled"
end if
Then in Script Editor.app
under Preferences
tab I enabled Show Script menu in menubar
checkbox (annotated in red):
as you can see, when you run the code it enable the proxy and if you run it again it will be disable.
Have a great day !