Skip to content

Instantly share code, notes, and snippets.

@ryanemmm
Created April 29, 2017 18:02
Show Gist options
  • Save ryanemmm/4b09fcd2b9c341b07f9a57579a753756 to your computer and use it in GitHub Desktop.
Save ryanemmm/4b09fcd2b9c341b07f9a57579a753756 to your computer and use it in GitHub Desktop.
toggle vpn connection from spotlight/launcher cuz I'm lazy
# 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