diff options
| author | Robert Günzler <r@gnzler.io> | 2026-04-08 13:11:48 +0900 |
|---|---|---|
| committer | Robert Günzler <r@gnzler.io> | 2026-04-08 13:11:48 +0900 |
| commit | d4620f3ac119263fee90bd819eadaf84fc8d50b7 (patch) | |
| tree | f5268e72a1c0037d29acac699e5d3f4c37be0e6b /.config/waybar/module-tailscale.sh | |
| parent | 8afe3fa8d88ae56e96f65897935ef508581ac5f7 (diff) | |
*
Automated-commit-by: dots Signed-off-by: Robert Günzler <r@gnzler.io>
Diffstat (limited to '.config/waybar/module-tailscale.sh')
| -rwxr-xr-x | .config/waybar/module-tailscale.sh | 33 |
1 files changed, 33 insertions, 0 deletions
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 '{}' |