This commit is contained in:
iFargle 2023-08-28 20:44:27 +09:00
parent 5974bd496c
commit 98ae22b400
2 changed files with 9 additions and 6 deletions

View file

@ -6,7 +6,6 @@
text = '' text = ''
#!/usr/bin/env bash #!/usr/bin/env bash
CLASS=`tailscale status --json | jq -r '.BackendState'` CLASS=`tailscale status --json | jq -r '.BackendState'`
TEXT="󰌆"
# Known values: Running, Stopped # Known values: Running, Stopped
# Expected Output: # Expected Output:
@ -14,12 +13,12 @@
# Different $Class depending on if TS is running or not # Different $Class depending on if TS is running or not
if [ $CLASS == "Running" ]; then if [ $CLASS == "Running" ]; then
IP=`tailscale status --json | jq -r '.TailscaleIPs[0]'` IP=`tailscale status --json | jq -r '.TailscaleIPs[0]'`
ALT="IP: $IP" TOOLTIP="IP: $IP"
printf '{"text": "%s", "class": "%s", "alt": "%s"}\n' "$TEXT" "$CLASS" "$ALT" printf '{"class": "%s", "tooltip": "%s"}\n' "$CLASS" "$TOOLTIP"
fi fi
if [ $CLASS == "Stopped" ]; then if [ $CLASS == "Stopped" ]; then
ALT="Tailscale is not running" TOOLTIP="Tailscale is not running"
printf '{"text": "%s", "class": "%s", "alt": "%s"}\n' "$TEXT" "$CLASS" "$ALT" printf '{"class": "%s", "tooltip": "%s"}\n' "$CLASS" "$TOOLTIP"
fi fi
''; '';
}; };

View file

@ -43,6 +43,10 @@
"exec-if": "pgrep tailscaled", "exec-if": "pgrep tailscaled",
"return-type": "json", "return-type": "json",
"interval": 5 "interval": 5
format-icons = {
"Running" = "󰌆",
"Stopped" = "󰌊",
}
}, },
"idle_inhibitor": { "idle_inhibitor": {
@ -215,7 +219,7 @@
#battery.critical, #battery.critical,
#custom-tailscale.Stopped, #custom-tailscale.Stopped,
#network.disconnected { #network.disconnected {
background-color: #fe8019; background-color: #f2594b;
} }
#battery.charging { #battery.charging {
color: #98971a; color: #98971a;