Last active
August 29, 2015 13:57
-
-
Save JerryFleming/9825310 to your computer and use it in GitHub Desktop.
Set proxy for all apps on Mac, including GUI and terminal, according to wi-fi AP name. Should be used together with proxy.sh <https://gist.github.com/JerryFleming/9825285>.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
property my_wifi : "off" | |
tell application "System Events" to tell menu bar 1 of process "SystemUIServer" of application "System Events" | |
set wifi_menu to first item of (value of attribute "AXChildren" as list) whose (value of attribute "AXDescription") contains "Wi-Fi" | |
tell wifi_menu | |
click | |
set my_wifi to (name of menu items of menu 1 whose name of attributes contains "AXMenuItemMarkChar" and value of attribute "AXMenuItemMarkChar" is "✓") | |
click | |
end tell | |
end tell | |
if my_wifi is equal to {"S3-wireless"} then | |
set param to "sgp" | |
else | |
set param to "none" | |
end if | |
do shell script "sed -i '' '/^\\. \\/etc\\/proxy/d' ~/.bash_profile ;echo '. /etc/proxy " & param & "' >> ~/.bash_profile" | |
do shell script "bash /etc/proxy " & param --with administrator privileges | |
display dialog "WiFi \"" & my_wifi & "\" requires \"" & param & "\" proxy." with title "Proxy Changed" buttons {"Ok"} with icon caution |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment