Adding Tailscale VPN

This commit is contained in:
iFargle 2023-08-28 20:35:07 +09:00
parent fa6599c2a9
commit 7ef93416fa
2 changed files with 20 additions and 5 deletions

View file

@ -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
'';
};
};

View file

@ -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;
}