Skip to content

Instantly share code, notes, and snippets.

@brucebentley
Last active March 2, 2020 09:37
Show Gist options
  • Select an option

  • Save brucebentley/0f1c37318929b664abf5bf765a89d487 to your computer and use it in GitHub Desktop.

Select an option

Save brucebentley/0f1c37318929b664abf5bf765a89d487 to your computer and use it in GitHub Desktop.
Keep your VPN connected ( macOS )
on idle
tell application "System Events"
tell current location of network preferences
set VPNService to the service "vpn-bruce" -- Replace this with the name of your VPN connection.
if VPNService is not null then
if current configuration of VPNService is not connected then
connect VPNService
end if
end if
end tell
-- In "idle" blocks, the number returned is how long to sleep until running again.
return 60
end tell
end idle
on idle
tell application "System Events"
tell current location of network preferences
set VPNService to the service "vpn-bruce" -- Replace this with the name of your VPN connection.
if VPNService is not null then
if current configuration of VPNService is not connected then
beep
beep
beep
connect VPNService
end if
end if
end tell
end tell
-- In "idle" blocks, the number returned is how long to sleep until running again.
return 60
end idle
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment