Skip to content

feat: add a Tunnelblick package that shows the VPN status - #37

Merged
Seb-GRAF merged 2 commits into
mainfrom
feat/tunnelblick
Nov 12, 2026
Merged

Seb-GRAF merged 2 commits into
mainfrom
feat/tunnelblick

Conversation

@Seb-GRAF

@Seb-GRAF Seb-GRAF commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

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.

Tunnelblick's bar widget: a filled shield with a lock in a white tile on a light grey background

Closes stablebox/StableBar#586

Changes

  • scripts/status.sh: asks application "Tunnelblick" is running first, as Amphetamine does, so it never launches Tunnelblick; when it isn't running, the widget outputs "hidden": true. Otherwise it gets the state and name of every configuration in one osascript call. CONNECTED means connected; EXITING means 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 answer count, so a repeat with … in configurations loop fails with error -1708; the script pairs the list of states with the list of names instead. It outputs the bar's icon, the popup's rows in lists.configurations and the Quick connect VPN in fields. 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 through openMenuBarItem: { "app": "net.tunnelblick.tunnelblick" }. The popup sets dismissOnAction: 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.
  • Manifest: the quickConnect setting, 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. minimumVersion 0.11.0, the first release with openMenuBarItem; it decodes every popup key the package uses. automation and accessibility permissions. The README's package list (./scripts/update-readme.sh).
  • preview.png: 520 × 144, the connected state. StableBar main drew it offscreen with --render-scenes from 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), and openOnHover takes 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.sh runs osascript twice 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.sh runs when a popup row or the Quick connect button is clicked: one osascript call that tells Tunnelblick to connect or disconnect the named configuration.
  • Permissions: automation, since macOS asks once to let StableBar control Tunnelblick, and accessibility, which openMenuBarItem needs on the first click.
  • Nothing in requires and no hosts.

Testing

  • scripts/check-package.sh packages/tunnelblick with STABLEBAR set to StableBar main (bb967e0, swift build -c release) and STABLEBAR_RELEASE set 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 EXITING for both, and the widget shows shield.slash, "Disconnected". control.sh's AppleScript compiles against Tunnelblick's dictionary (osacompile, not run).

  • Offline, status.sh with a fake osascript that replays the recorded output format (state, tab, name per line):

    Tunnelblick Configurations Quick connect Bar Popup
    not running hidden, no second osascript call
    running none shield.slash, "Disconnected" no rows
    running Office EXITING, Home EXITING shield.slash, "Disconnected" both rows, Connect
    running Office EXITING, Home GET_CONFIG shield.lefthalf.filled, "Connecting" Home Connecting, Disconnect
    running Home GET_CONFIG, Office EXITING shield.lefthalf.filled, "Connecting"
    running Office CONNECTED, Home AUTH lock.shield.fill, "Connected to Office"
    running two CONNECTED, one name with ', " and \ both names in the tooltip, valid JSON
    running Office EXITING, Home CONNECTED Office "Connected to Home" Office first, Connect; Home row, Disconnect
    running Office AUTH, Home EXITING Office "Connecting" Office first, Disconnect
    running Office CONNECTED, Home EXITING Office "Connected to Office" Office first, Disconnect
    running Office, Home Lab no Quick connect row, both rows
  • Each row's command, run through zsh -c as StableBar runs it, reaches the fake osascript with the exact name, including one with ', ", \, ;, $(…) and backticks; nothing in it runs. With a real osascript and an AppleScript that only returns its arguments, on run {action, vpn} receives such a name intact.

  • The popup, drawn offscreen with --render-scenes in 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/main and scripts/check-one-package.sh origin/main pass.

  • 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

@Seb-GRAF
Seb-GRAF merged commit e463eef into main Nov 12, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Show Tunnelblick's connection status on the bar

1 participant