diff --git a/home-manager/hosts/nixos-laptop/desktops/hyprland/gruvbox/waybar/scripts/waybar-scripts.nix b/home-manager/hosts/nixos-laptop/desktops/hyprland/gruvbox/waybar/scripts/waybar-scripts.nix index 7818a64d..bf215cb7 100644 --- a/home-manager/hosts/nixos-laptop/desktops/hyprland/gruvbox/waybar/scripts/waybar-scripts.nix +++ b/home-manager/hosts/nixos-laptop/desktops/hyprland/gruvbox/waybar/scripts/waybar-scripts.nix @@ -4,7 +4,22 @@ enable = true; executable = true; text = '' - tailscale status --json | jq -r '.BackendState' + #!/usr/bin/env bash + CLASS=`tailscale status --json | jq -r '.BackendState'` + # Known values: Running, Stopped + + # Expected Output: + # {"text": "$text", "alt": "$alt", "tooltip": "$tooltip", "class": "$class", "percentage": $percentage } + # Different $Class depending on if TS is running or not + if [ $CLASS == "Running" ]; then + IP=`tailscale status --json | jq -r '.TailscaleIPs[0]'` + ALT="IP: $IP" + printf '{"class": %s", "alt": %s}' "$CLASS", "$ALT" + fi + if [ $CLASS == "Stopped" ]; then + ALT="Tailscale is not running" + printf '{"class": %s", "alt": %s}' "$CLASS", "$ALT" + fi ''; }; }; diff --git a/home-manager/hosts/nixos-laptop/desktops/hyprland/gruvbox/waybar/waybar-conf2.nix b/home-manager/hosts/nixos-laptop/desktops/hyprland/gruvbox/waybar/waybar-conf2.nix index a751c909..7a3379d3 100644 --- a/home-manager/hosts/nixos-laptop/desktops/hyprland/gruvbox/waybar/waybar-conf2.nix +++ b/home-manager/hosts/nixos-laptop/desktops/hyprland/gruvbox/waybar/waybar-conf2.nix @@ -39,9 +39,9 @@ ], "custom/tailscale": { - "format": "VPN ", - "exec": "echo '{\"class\": \"connected\"}'", - "exec-if": "", + "format": "{} 󰌆", + "exec": "$HOME/.config/waybar/scripts/tailscale.sh", + "exec-if": "pgrep tailscaled", "return-type": "json", "interval": 5 }, @@ -198,7 +198,7 @@ /* new stuff */ border-radius: 5px; color: rgba(50, 48, 47, 0.8); - background-color: #e2cca9; + background-color: #d5c4a1; font-weight: bold; }