Add waybar config
This commit is contained in:
41
tree/.local/bin/mullvad-waybar
Executable file
41
tree/.local/bin/mullvad-waybar
Executable file
@ -0,0 +1,41 @@
|
||||
#!/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'"}'
|
||||
|
||||
Reference in New Issue
Block a user