Skip to content

Instantly share code, notes, and snippets.

@san-young
Last active July 4, 2025 07:55
Show Gist options
  • Select an option

  • Save san-young/d1e088721b49b085dd5ef9981c4ec67b to your computer and use it in GitHub Desktop.

Select an option

Save san-young/d1e088721b49b085dd5ef9981c4ec67b to your computer and use it in GitHub Desktop.
Run FortiClient config
-- 1. Install https://github.com/Hammerspoon/hammerspoon
-- 2. Change var "vpnProfileName" as your config named in FortiClient
-- 3. Put this config to ~/.hammerspoon/init.lua
-- 4. Reload Hammerspoon config
local vpnProfileName = "Split"
local hotkey = {"cmd", "alt"}
local key = "f"
function performVpnActionViaOsascript()
local appleScriptCode = string.format([[
tell application "System Events" to tell process "FortiTray"
try
set theMenuItem to menu item "Connect to %s" of menu 1 of menu bar item 1 of menu bar 1
perform action "AXPress" of theMenuItem
end try
end tell
]], vpnProfileName)
local shellCommand = "osascript -e '" .. appleScriptCode .. "'"
hs.execute(shellCommand)
end
hs.hotkey.bind(hotkey, key, performVpnActionViaOsascript)
hs.alert.show((string.format("FortiVPN Hotkey (%s + %s)", string.upper(table.concat(hotkey, " + ")), string.upper(key))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment