Change text in mullvad waybar component

This commit is contained in:
2021-04-26 20:17:48 +02:00
parent f1955208eb
commit 8f54bec168

View File

@ -2,8 +2,8 @@
if ! which mullvad &> /dev/null if ! which mullvad &> /dev/null
then then
echo "ERROR: command 'mullvad' does not exist" echo "ERROR: command 'mullvad' does not exist"
exit 1 exit 1
fi fi
STATUS="$(mullvad status)" STATUS="$(mullvad status)"
@ -13,26 +13,24 @@ CONNECTED="Tunnel status: Connected"
DISCONNECTED="Tunnel status: Disconnected" DISCONNECTED="Tunnel status: Disconnected"
check_status() { check_status() {
STRING="$1" STRING="$1"
echo "$STATUS" | grep -iq "$STRING" echo "$STATUS" | grep -iq "$STRING"
} }
TOOLTIP="$STATUS" TOOLTIP="$STATUS"
TEXT="VPN"
if check_status "$CONNECTED"; then if check_status "$CONNECTED"; then
TEXT="Connected"
ON_CLICK="mullvad disconnect" ON_CLICK="mullvad disconnect"
CLASS="" CLASS=""
elif check_status "$DISCONNECTED"; then elif check_status "$DISCONNECTED"; then
TEXT="Disconnected"
ON_CLICK="mullvad connect" ON_CLICK="mullvad connect"
CLASS="disconnected" CLASS="disconnected"
elif check_status "$CONNECTING"; then elif check_status "$CONNECTING"; then
TEXT="Connecting..."
ON_CLICK="mullvad disconnect" ON_CLICK="mullvad disconnect"
CLASS="connecting" CLASS="connecting"
else else
TEXT="Error"
ON_CLICK="mullvad reconnect" ON_CLICK="mullvad reconnect"
CLASS="disconnected" CLASS="disconnected"
fi fi