Skip to content

Instantly share code, notes, and snippets.

@varenc
Last active April 12, 2025 22:12
Show Gist options
  • Save varenc/b9ce6e1ffd8248ff83ea0e68e1bdb498 to your computer and use it in GitHub Desktop.
Save varenc/b9ce6e1ffd8248ff83ea0e68e1bdb498 to your computer and use it in GitHub Desktop.
Swiftbar plug-in for displaying Tailscale's --accept-routes and --exit-node status
#!/bin/sh
# Swiftbar plugin for displaying Tailscale's --accept-routes and --exit-node status
#
# Status indicators:
# ✅ = accepting routes
# ❌ = not accepting routes (or accepting, but no peers advertising routes)
# ➡️ = using an exit node
# ❓ = Tailscale not running
#
# Possible outputs:
# TS✅ = Tailscale running, accepting routes
# TS❌ = Tailscale running, not accepting routes
# TS✅➡️ = Tailscale running, accepting routes, using exit node
# TS❌➡️ = Tailscale running, not accepting routes, using exit node
# TS❓ = Tailscale not running
if ! output=$(/Applications/Tailscale.app/Contents/MacOS/Tailscale status --json 2>/dev/null); then
echo "TS❓"
exit 1
fi
jq -r '"TS" + (
if any(.Health[]; contains("Some peers are advertising")) then
"❌"
else
"✅"
end
) + (
.ExitNodeStatus | if . then "➡️" else "" end
)' <<<"$output"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment