Repository navigation
feat: add a Tunnelblick package that shows the VPN status - #37
Merged
Merged
Conversation
Seb-GRAF
force-pushed
the
feat/tunnelblick
branch
from
November 12, 2026 08:36
50b5f13 to
9dfcb47
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Package
Tunnelblick 1.0.0, a new package. Tunnelblick's menu bar icon changes with the connection, but StableBar's Menu bar items row draws its app icon instead, so with the macOS menu bar hidden the state is lost. This widget shows a symbol for the state: connected (
lock.shield.fill), connecting (shield.lefthalf.filled) or disconnected (shield.slash). Its tooltip names the connected configuration, such as "Connected to Office". It hides while Tunnelblick isn't running.Clicking it opens a popup that lists every Tunnelblick configuration with its state. Clicking a row connects it when it's disconnected, and disconnects it when it's connected or connecting. The Quick connect VPN, when set, comes first with its own Connect or Disconnect button. Open Tunnelblick at the bottom opens Tunnelblick's own menu, as clicking its icon in the menu bar does.
Closes stablebox/StableBar#586
Changes
scripts/status.sh: asksapplication "Tunnelblick" is runningfirst, as Amphetamine does, so it never launches Tunnelblick; when it isn't running, the widget outputs"hidden": true. Otherwise it gets thestateandnameof every configuration in oneosascriptcall.CONNECTEDmeans connected;EXITINGmeans disconnected or disconnecting; any other state is a step towards a connection, as Tunnelblick's scripting dictionary says. One connected configuration makes the widget connected, whatever the others do; otherwise one connecting makes it connecting. Tunnelblick doesn't answercount, so arepeat with … in configurationsloop fails with error -1708; the script pairs the list of states with the list of names instead. It outputs the bar'sicon, the popup's rows inlists.configurationsand the Quick connect VPN infields. Each row carries its command,control.sh Connect|Disconnect '<name>', with the name single-quoted for the shell, as Development servers and Quick ask quote theirs with@sh.scripts/control.sh: connects or disconnects one configuration. The action and the name reach AppleScript as arguments (on run {action, vpn}), never as script text, so names with quotes or spaces are safe.config.json: a script widget polled every 5 seconds, like Amphetamine, with a popup: the title, the Quick connect row (hidden when it's not set), the other configurations, then Open Tunnelblick throughopenMenuBarItem: { "app": "net.tunnelblick.tunnelblick" }. The popup setsdismissOnAction: false, so it stays open after a click; StableBar refreshes the widget when the action finishes and then every 5 seconds, so a row goes from Disconnected to Connecting to Connected while the popup is open. Tokens and row styles follow Amphetamine's popup.quickConnectsetting, a text field, empty by default, with a description that says to type the VPN's name as Tunnelblick shows it, since package settings can't list the user's VPNs.minimumVersion0.11.0, the first release withopenMenuBarItem; it decodes every popup key the package uses.automationandaccessibilitypermissions. The README's package list (./scripts/update-readme.sh).preview.png: 520 × 144, the connected state. StableBarmaindrew it offscreen with--render-scenesfrom the installed package, using the scene and bar settings from feat: add a preview for the Amphetamine package #30, and the scene frame's rounded edge was painted over with the background colour. The bar draws pixel for pixel the same as before the popup was added, so it hasn't changed.A Quick connect name that Tunnelblick doesn't have is ignored: the popup lists every configuration, with no Quick connect row.
A When clicked setting, with a mode where clicking connects or disconnects the Quick connect VPN and resting the pointer opens the popup, isn't in this pull request. In StableBar, a widget's popup takes its click (
BarView.swift,clickable), andopenOnHovertakes only a bool, which a string setting can't provide and a script can't receive, so a package can't switch between those modes on its own.Access
scripts/status.shrunsosascripttwice per refresh: once to check that Tunnelblick is running, once to read the state and name of its configurations. It changes nothing, writes no files and contacts no hosts.scripts/control.shruns when a popup row or the Quick connect button is clicked: oneosascriptcall that tells Tunnelblick toconnectordisconnectthe named configuration.automation, since macOS asks once to let StableBar control Tunnelblick, andaccessibility, whichopenMenuBarItemneeds on the first click.requiresand nohosts.Testing
scripts/check-package.sh packages/tunnelblickwithSTABLEBARset to StableBarmain(bb967e0,swift build -c release) andSTABLEBAR_RELEASEset to 0.13.0, the latest release: the file and preview checks, inspect, install into a scratch configuration and validate pass with both ("Valid configuration: 1 widgets in 3 files").Live, against Tunnelblick 8.0 (build 6300) on macOS 27.2.1 with two configurations, both disconnected: the state read returns
EXITINGfor both, and the widget showsshield.slash, "Disconnected".control.sh's AppleScript compiles against Tunnelblick's dictionary (osacompile, not run).Offline,
status.shwith a fakeosascriptthat replays the recorded output format (state, tab, name per line):hidden, no secondosascriptcallshield.slash, "Disconnected"EXITING, HomeEXITINGshield.slash, "Disconnected"EXITING, HomeGET_CONFIGshield.lefthalf.filled, "Connecting"GET_CONFIG, OfficeEXITINGshield.lefthalf.filled, "Connecting"CONNECTED, HomeAUTHlock.shield.fill, "Connected to Office"CONNECTED, one name with',"and\EXITING, HomeCONNECTEDAUTH, HomeEXITINGCONNECTED, HomeEXITINGEach row's command, run through
zsh -cas StableBar runs it, reaches the fakeosascriptwith the exact name, including one with',",\,;,$(…)and backticks; nothing in it runs. With a realosascriptand an AppleScript that only returns its arguments,on run {action, vpn}receives such a name intact.The popup, drawn offscreen with
--render-scenesin light and dark, with and without a Quick connect VPN.ShellCheck 0.11.0,
scripts/test.sh,scripts/check-suggestions.sh,scripts/check-versions.sh origin/mainandscripts/check-one-package.sh origin/mainpass.Not checked live: connecting or disconnecting a VPN, a connected or connecting state, the popup on a bar, its clicks, Open Tunnelblick, and macOS's Automation prompt for StableBar. I didn't change the VPN connections on this Mac or launch StableBar.
Claude Opus 5.5 via Claude Code