From 93314d450f29eae6eb37f4e4554f036d66a1723a Mon Sep 17 00:00:00 2001 From: Liam Woodleigh-Hardinge Date: Thu, 27 Aug 2026 13:00:46 +0200 Subject: [PATCH] tailscale: add hide_when_healthy and flag_problem widget settings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two independent, opt-in status-widget settings (both default false, so existing behaviour is unchanged): - hide_when_healthy collapses the widget entirely while Tailscale runs; it appears only when the daemon is stopped, needs login, or is unreachable — for people who want the bar quiet unless something is wrong. The /ts launcher provider still works while hidden. - flag_problem tints the status dot with the palette's error role while Tailscale is not running (and shows that dot even with show_counts off), instead of the neutral grey — for permanently-visible widgets that should read as an alert. --- tailscale/README.md | 2 ++ tailscale/plugin.toml | 16 +++++++++++++- tailscale/translations/en.json | 8 +++++++ tailscale/widget.luau | 39 +++++++++++++++++++++++++++++++--- 4 files changed, 61 insertions(+), 4 deletions(-) diff --git a/tailscale/README.md b/tailscale/README.md index a20f83698..9e868dd0d 100644 --- a/tailscale/README.md +++ b/tailscale/README.md @@ -48,6 +48,8 @@ noctalia msg panel-toggle davemhammer/tailscale:manager | `admin_url` | `string` | _(empty)_ | Override admin console URL (default login.tailscale.com admin). | | `ssh_user` | `string` | _(empty)_ | Default user for `tailscale ssh`. | | `show_counts` | `bool` (widget) | `true` | Show online/total peers on the bar. | +| `hide_when_healthy` | `bool` (widget) | `false` | Hide the widget entirely while Tailscale runs; it appears only when the daemon is stopped, needs login, or is unreachable. | +| `flag_problem` | `bool` (widget) | `false` | Error-tinted status dot while Tailscale is not running, instead of the neutral grey one. | ## IPC diff --git a/tailscale/plugin.toml b/tailscale/plugin.toml index ea2b56fad..5e014fe25 100644 --- a/tailscale/plugin.toml +++ b/tailscale/plugin.toml @@ -2,7 +2,7 @@ id = "davemhammer/tailscale" name = "Tailscale" -version = "1.0.6" +version = "1.1.0" plugin_api = 10 author = "davemhammer" license = "MIT" @@ -62,6 +62,20 @@ entry = "widget.luau" description_key = "settings.show_counts.description" default = true + [[widget.setting]] + key = "hide_when_healthy" + type = "bool" + label_key = "settings.hide_when_healthy.label" + description_key = "settings.hide_when_healthy.description" + default = false + + [[widget.setting]] + key = "flag_problem" + type = "bool" + label_key = "settings.flag_problem.label" + description_key = "settings.flag_problem.description" + default = false + [[panel]] id = "manager" entry = "panel.luau" diff --git a/tailscale/translations/en.json b/tailscale/translations/en.json index afb1d7534..15a7568d8 100644 --- a/tailscale/translations/en.json +++ b/tailscale/translations/en.json @@ -135,6 +135,14 @@ }, "warn_color": { "label": "Disconnected color (grey)" + }, + "hide_when_healthy": { + "label": "Hide when healthy", + "description": "Hide the widget entirely while Tailscale is running; show it only when the daemon is stopped, needs login, or is unreachable." + }, + "flag_problem": { + "label": "Flag problems in red", + "description": "Show an error-tinted status dot while Tailscale is not running, instead of the neutral grey one." } }, "status": { diff --git a/tailscale/widget.luau b/tailscale/widget.luau index 93cc2f122..837d92d47 100644 --- a/tailscale/widget.luau +++ b/tailscale/widget.luau @@ -32,7 +32,30 @@ local function render() local exitNode = tostring(snapshot.exitNode or "") local hasExit = exitNode ~= "" - -- Connected = green logo, stopped = grey logo (never red). + -- Two independent, opt-in settings (both default false — behaviour is + -- unchanged unless a widget instance turns one on): + -- hide_when_healthy — collapse to nothing while running. + -- flag_problem — error-tinted status dot while not running, + -- instead of the neutral grey one. + -- They compose: a permanently-visible widget can still flag a problem, + -- and a hidden-while-healthy widget stays reachable via the /ts + -- launcher provider whenever it matters. + local hideWhenHealthy = noctalia.getConfig("hide_when_healthy") == true + local flagProblem = noctalia.getConfig("flag_problem") == true + + if hideWhenHealthy then + if running then + barWidget.setVisible(false) + return + end + barWidget.setVisible(true) + end + + -- Connected = green logo, stopped = grey logo (never red) — except + -- with flag_problem on, where the one non-connected state earns the + -- error colour, since that setting exists to make a permanently- + -- visible widget read as an alert. + local isProblem = flagProblem and not running local color = running and COLOR_CONNECTED or COLOR_DISCONNECTED local children = { @@ -44,7 +67,17 @@ local function render() }), } - if showCounts and available then + if isProblem and not (showCounts and available) then + -- Restrained problem indicator when there is nothing else to show: + -- brand mark plus an error-tinted dot, no counts/exit-node detail — + -- that stays in the manager panel this widget opens on click. + table.insert(children, ui.box({ + width = 7, + height = 7, + radius = 4, + fill = "error", + })) + elseif showCounts and available then table.insert(children, ui.label({ text = `{online}/{total}`, fontWeight = "bold", @@ -61,7 +94,7 @@ local function render() width = 7, height = 7, radius = 4, - fill = color, + fill = isProblem and "error" or color, })) end