diff --git a/waybar/config.jsonc b/waybar/config.jsonc index 944bfea..984d015 100644 --- a/waybar/config.jsonc +++ b/waybar/config.jsonc @@ -15,6 +15,7 @@ "pulseaudio", "clock", "clock#simpleclock", + "custom/tailscale", "network", "battery", "tray", @@ -151,6 +152,13 @@ "return-type": "json", "tooltip": false, }, + "custom/tailscale": { + "exec": "~/.config/waybar/scripts/tailscale.sh", + "interval": 5, + "return-type": "json", + "on-click": "~/.config/waybar/scripts/tailscale-toggle.sh", + "tooltip": true + }, "network": { "interface": "wlp1s0", "format": "", diff --git a/waybar/scripts/tailscale-toggle.sh b/waybar/scripts/tailscale-toggle.sh new file mode 100755 index 0000000..dbaf3c7 --- /dev/null +++ b/waybar/scripts/tailscale-toggle.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +if tailscale status --json 2>/dev/null | grep -q '"BackendState": "Running"'; then + tailscale down +else + tailscale up +fi diff --git a/waybar/scripts/tailscale.sh b/waybar/scripts/tailscale.sh new file mode 100755 index 0000000..804f0bd --- /dev/null +++ b/waybar/scripts/tailscale.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +if tailscale status --json 2>/dev/null | grep -q '"BackendState": "Running"'; then + echo '{"text":"󰖂 Connected","class":"connected","tooltip":"Tailscale Connected"}' +else + echo '{"text":"󱗼 Disconnected","class":"disconnected","tooltip":"Tailscale Disconnected"}' +fi diff --git a/waybar/style.css b/waybar/style.css index 1c75c87..3266972 100644 --- a/waybar/style.css +++ b/waybar/style.css @@ -76,6 +76,7 @@ window#waybar { #custom-power, #custom-spotify, #custom-notification, +#custom-tailscale, #cpu, #tray, #memory,