From d4620f3ac119263fee90bd819eadaf84fc8d50b7 Mon Sep 17 00:00:00 2001 From: Robert Günzler Date: Wed, 8 Apr 2026 13:11:48 +0900 Subject: * MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Automated-commit-by: dots Signed-off-by: Robert Günzler --- .config/waybar/module-tailscale.sh | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 .config/waybar/module-tailscale.sh (limited to '.config/waybar/module-tailscale.sh') diff --git a/.config/waybar/module-tailscale.sh b/.config/waybar/module-tailscale.sh new file mode 100755 index 0000000..53b0409 --- /dev/null +++ b/.config/waybar/module-tailscale.sh @@ -0,0 +1,33 @@ +#!/bin/bash +set -eu +[ -n "${DEBUG:-}" ] && set -x + +update() { + local ts_acct ts_ip + local class text alt + + if tailscale status | grep -q stopped; then + return 1 + fi + + ts_ip=$(tailscale ip -1 || return 1) + ts_acct=$(tailscale switch --list 2>/dev/null | awk '/\*$/{ print gensub(/^.* ([^ ]+)\*$/, "\\1", "1") }') + + alt="$ts_acct" + class="$ts_acct" + # only display account name when not "main" + [ "$ts_acct" = "main" ] || text=$ts_acct + + if tailscale exit-node list | grep -q selected; then + alt="exit-node" + class="exit-node" + fi + + jq -nrc '{text:$text,tooltip:$tip,class:$class,alt:$alt}' \ + --arg tip "${ts_ip:?}" \ + --arg class "${class:?}" \ + --arg alt "${alt:?}" \ + --arg text "${text:-}" +} + +update || echo '{}' -- cgit 1.4.1