This commit is contained in:
zack 2025-05-09 18:43:27 -04:00
parent dd60fce00f
commit fdd9dd20ae
No known key found for this signature in database
GPG key ID: EE8A2B709E2401D1
14 changed files with 544 additions and 204 deletions

View file

@ -0,0 +1,35 @@
#!/usr/bin/env bash
set -euo pipefail
# Get status (fall back to “Disconnected” on error)
STATUS=$(mullvad status 2>/dev/null || echo "Disconnected")
if echo "$STATUS" | grep -q "^Connected"; then
# Extract relay hostname
SERVER=$(echo "$STATUS" |
sed -n 's/^[[:space:]]*Relay:[[:space:]]*//p' |
sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
# Grab the entire Visible location line (location + IPs)
FULL_LOC=$(echo "$STATUS" |
sed -n 's/^[[:space:]]*Visible location:[[:space:]]*//p')
# Split off the humanreadable location (before first dot)
LOCATION=${FULL_LOC%%.*}
# The part after the first “. ” is the IP info
IPS=${FULL_LOC#*. }
TOOLTIP="Connected via ${SERVER} (${IPS})"
# Emit JSON for Waybar
echo '{"text": "'"${LOCATION}"'"
, "tooltip": "'"${TOOLTIP}"'"
, "class": "connected"
}'
else
echo '{"text": "Disconnected"
, "tooltip": "Mullvad: Disconnected"
, "class": "disconnected"
}'
fi