nix/home-manager/hosts/nixos-laptop/desktops/hyprland/gruvbox/scripts/waybar-scripts.nix

26 lines
1.1 KiB
Nix
Raw Normal View History

2023-08-28 12:35:59 +02:00
{...}: {
home.file = {
".config/waybar/scripts/tailscale.sh" = {
enable = true;
executable = true;
text = ''
2023-08-28 13:35:07 +02:00
#!/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]'`
2023-08-28 13:44:27 +02:00
TOOLTIP="IP: $IP"
2023-08-28 13:52:07 +02:00
printf '{"class": "%s", "tooltip": "%s", "alt": "%s"}\n' "$CLASS" "$TOOLTIP" "$CLASS"
2023-08-28 13:35:07 +02:00
fi
if [ $CLASS == "Stopped" ]; then
2023-08-28 13:44:27 +02:00
TOOLTIP="Tailscale is not running"
2023-08-28 13:52:07 +02:00
printf '{"class": "%s", "tooltip": "%s", "alt": "%s"}\n' "$CLASS" "$TOOLTIP" "$CLASS"
2023-08-28 13:35:07 +02:00
fi
2023-08-28 12:35:59 +02:00
'';
2023-08-28 12:39:04 +02:00
};
};
2023-08-28 12:35:59 +02:00
}