Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions tailscale/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
16 changes: 15 additions & 1 deletion tailscale/plugin.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

id = "davemhammer/tailscale"
name = "Tailscale"
version = "1.0.6"
version = "1.1.0"
plugin_api = 10
author = "davemhammer"
license = "MIT"
Expand Down Expand Up @@ -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"
Expand Down
8 changes: 8 additions & 0 deletions tailscale/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
39 changes: 36 additions & 3 deletions tailscale/widget.luau
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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",
Expand All @@ -61,7 +94,7 @@ local function render()
width = 7,
height = 7,
radius = 4,
fill = color,
fill = isProblem and "error" or color,
}))
end

Expand Down
Loading