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'`
|
2023-08-28 13:36:58 +02:00
|
|
|
TEXT=""
|
2023-08-28 13:35:07 +02:00
|
|
|
# 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"
|
2023-08-28 13:36:58 +02:00
|
|
|
printf '{"text": %s,"class": %s", "alt": %s}\n' "$TEXT" "$CLASS" "$ALT"
|
2023-08-28 13:35:07 +02:00
|
|
|
fi
|
|
|
|
if [ $CLASS == "Stopped" ]; then
|
|
|
|
ALT="Tailscale is not running"
|
2023-08-28 13:36:58 +02:00
|
|
|
printf '{"text": %s,"class": %s", "alt": %s}\n' "$TEXT" "$CLASS" "$ALT"
|
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
|
|
|
}
|