42 lines
828 B
Bash
Executable File
42 lines
828 B
Bash
Executable File
#!/bin/sh
|
|
|
|
if ! which mullvad &> /dev/null
|
|
then
|
|
echo "ERROR: command 'mullvad' does not exist"
|
|
exit 1
|
|
fi
|
|
|
|
STATUS="$(mullvad status)"
|
|
|
|
CONNECTING="Tunnel status: Connecting"
|
|
CONNECTED="Tunnel status: Connected"
|
|
DISCONNECTED="Tunnel status: Disconnected"
|
|
|
|
check_status() {
|
|
STRING="$1"
|
|
echo "$STATUS" | grep -iq "$STRING"
|
|
}
|
|
|
|
TOOLTIP="$STATUS"
|
|
|
|
if check_status "$CONNECTED"; then
|
|
TEXT="Connected"
|
|
ON_CLICK="mullvad disconnect"
|
|
CLASS=""
|
|
elif check_status "$DISCONNECTED"; then
|
|
TEXT="Disconnected"
|
|
ON_CLICK="mullvad connect"
|
|
CLASS="disconnected"
|
|
elif check_status "$CONNECTING"; then
|
|
TEXT="Connecting..."
|
|
ON_CLICK="mullvad disconnect"
|
|
CLASS="connecting"
|
|
else
|
|
TEXT="Error"
|
|
ON_CLICK="mullvad reconnect"
|
|
CLASS="disconnected"
|
|
fi
|
|
|
|
echo '{"text":"'$TEXT'", "tooltip":"'$TOOLTIP'", "class":"'$CLASS'"}'
|
|
|