From e93df78c688ce12812bb609e0029425d15803892 Mon Sep 17 00:00:00 2001 From: Scott Ames Date: Sun, 29 Dec 2024 07:16:39 -0800 Subject: [PATCH] feat(waybar): add tailscale indicator --- home/private_dot_config/waybar/config.jsonc | 17 ++++++++++++++++- .../waybar/scripts/executable_tailscale.sh | 14 ++++++++++++++ home/private_dot_config/waybar/style.css | 17 ++++++++++++++--- 3 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 home/private_dot_config/waybar/scripts/executable_tailscale.sh diff --git a/home/private_dot_config/waybar/config.jsonc b/home/private_dot_config/waybar/config.jsonc index 06a8316b..2b1568ff 100644 --- a/home/private_dot_config/waybar/config.jsonc +++ b/home/private_dot_config/waybar/config.jsonc @@ -17,9 +17,10 @@ "temperature", "power-profiles-daemon", "disk", - "battery", "backlight", "network", + "custom/tailscale", + "battery", "pulseaudio", "custom/lock", "custom/power" @@ -124,6 +125,20 @@ "󰁹" ] }, + "custom/tailscale": { + "exec": "~/.config/waybar/scripts/tailscale.sh", + "interval": 10, + "format": "{}", + "tooltip": true, + "return-type": "json" + }, + "network#tailscale": { + "interface": "tailscale0", + "format": "󰌆", + "format-disconnected": "󰌊", + "tooltip-format": "{ifname}: {bandwidthUpBits} {bandwidthDownBits}", + "tooltip-format-disconnected": "disconnected", + }, "network": { "format-wifi": " ", "format-ethernet": "", diff --git a/home/private_dot_config/waybar/scripts/executable_tailscale.sh b/home/private_dot_config/waybar/scripts/executable_tailscale.sh new file mode 100644 index 00000000..45f11cfc --- /dev/null +++ b/home/private_dot_config/waybar/scripts/executable_tailscale.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +if tailscale status &>/dev/null; then + if tailscale exit-node list | grep -q selected; then + tooltip=$(tailscale exit-node list | grep selected | awk '{print $2" "$3}') + echo "{\"text\": \" \", \"class\": \"enabled\", \"tooltip\": \"${tooltip}\"}" + else + tooltip="No exit-node assigned" + echo "{\"text\": \" \", \"class\": \"disabled\", \"tooltip\": \"${tooltip}\"}" + fi +else + tooltip="Tailscale is not connected" + echo "{\"text\": \" \", \"class\": \"disabled\", \"tooltip\": \"${tooltip}\"}" +fi diff --git a/home/private_dot_config/waybar/style.css b/home/private_dot_config/waybar/style.css index c2135a7c..6b57e98b 100644 --- a/home/private_dot_config/waybar/style.css +++ b/home/private_dot_config/waybar/style.css @@ -57,6 +57,7 @@ tooltip { #custom-caffeine, #custom-lock, #custom-power, +#custom-tailscale, #disk, #battery, #cpu, @@ -98,7 +99,8 @@ tooltip { #battery { color: @green; border-left: 0px; - border-right: 0px; + border-radius: 0 10px 10px 0; + margin-right: 10px; } #clock { @@ -156,8 +158,17 @@ tooltip { #network { color: @text; border-left: 0px; - border-radius: 0 10px 10px 0; - margin-right: 10px; + border-right: 0px; +} + +#custom-tailscale { + color: @text; + border-left: 0px; + border-right: 0px; + color: @red; +} +#custom-tailscale.enabled { + color: @green; } #custom-power {