Last active
July 4, 2025 07:55
-
-
Save san-young/d1e088721b49b085dd5ef9981c4ec67b to your computer and use it in GitHub Desktop.
Run FortiClient config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- 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