Skip to content

Instantly share code, notes, and snippets.

@CheyiLin
Last active May 7, 2021 09:17
Show Gist options
  • Save CheyiLin/0beb9a42ab1900692acb5737ad91db0d to your computer and use it in GitHub Desktop.
Save CheyiLin/0beb9a42ab1900692acb5737ad91db0d to your computer and use it in GitHub Desktop.
A simple AppleScript to prevent VPN session from timing out
on idle
set checkIval to 60
set vpnName to "YOUR_VPN_NAME"
set pingDest to "PING_DEST_THRU_VPN"
tell application "System Events"
tell current location of network preferences
set vpnConn to service vpnName
if vpnConn is not null then
if current configuration of vpnConn is connected then
do shell script "ping -c 3 " & pingDest
end if
end if
end tell
return checkIval
end tell
end idle
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment