Skip to content

Instantly share code, notes, and snippets.

@trevor-atlas
Created June 30, 2023 19:36
Show Gist options
  • Save trevor-atlas/45ea4ba63553e81facc93105cf52dc65 to your computer and use it in GitHub Desktop.
Save trevor-atlas/45ea4ba63553e81facc93105cf52dc65 to your computer and use it in GitHub Desktop.
// Name: vpn
// Schedule: */15 * * * *
import "@johnlindquist/kit"
applescript(`
tell application "System Events" to tell process "GlobalProtect"
set connectionStatus to get help of every menu bar item of menu bar 2
if item 1 of connectionStatus = "Not Connected" then
click menu bar item 1 of menu bar 2 -- Activates the GlobalProtect "window" in the menubar
try
click button "Connect" of window 1
end try
click menu bar item 1 of menu bar 2 -- This will close the GlobalProtect "window" after clicking Connect/Disconnect. This is optional.
end if
end tell
`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment