Add eww helper scripts
This commit is contained in:
41
tree/.local/bin/mullvad-status
Executable file
41
tree/.local/bin/mullvad-status
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="Connecting"
|
||||
CONNECTED="Connected"
|
||||
DISCONNECTED="Disconnected"
|
||||
|
||||
check_status() {
|
||||
STRING="$1"
|
||||
echo "$STATUS" | grep -iq "$STRING"
|
||||
}
|
||||
|
||||
TOOLTIP="$STATUS"
|
||||
ICON=""
|
||||
ON_CLICK=""
|
||||
|
||||
|
||||
if check_status "$DISCONNECTED"; then
|
||||
CLASS="disconnected"
|
||||
ON_CLICK="mullvad connect"
|
||||
elif check_status "$CONNECTED"; then
|
||||
CLASS=""
|
||||
ICON=""
|
||||
ON_CLICK="mullvad disconnect"
|
||||
elif check_status "$CONNECTING"; then
|
||||
CLASS="connecting"
|
||||
ON_CLICK="mullvad disconnect"
|
||||
else
|
||||
CLASS="disconnected"
|
||||
ON_CLICK="mullvad connect"
|
||||
fi
|
||||
|
||||
echo '{"icon":"'$ICON'", "tooltip":"'$TOOLTIP'", "class":"'$CLASS'", "on_click": "'$ON_CLICK'"}'
|
||||
|
||||
Reference in New Issue
Block a user