Created
April 29, 2017 18:02
-
-
Save ryanemmm/4b09fcd2b9c341b07f9a57579a753756 to your computer and use it in GitHub Desktop.
toggle vpn connection from spotlight/launcher cuz I'm lazy
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
# adapted from: https://gist.github.com/adgedenkers/3874427 | |
# VPN_NAME is the name of your vpn | |
-- adapted from https://gist.github.com/adgedenkers/3874427 | |
tell application "System Events" | |
-- start playing with the VPN | |
tell current location of network preferences | |
-- set the name of the VPN service from your Network Settings | |
set VPNService to service "VPN_NAME" | |
-- determine current VPN connection status | |
set isConnected to connected of current configuration of VPNService | |
-- if connected, then disconnect | |
if isConnected then | |
disconnect VPNService | |
else -- otherwise, connect to the VPN | |
connect VPNService | |
end if | |
end tell | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment