#!/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" TEXT="VPN" if check_status "$CONNECTED"; then ON_CLICK="mullvad disconnect" CLASS="" elif check_status "$DISCONNECTED"; then ON_CLICK="mullvad connect" CLASS="disconnected" elif check_status "$CONNECTING"; then ON_CLICK="mullvad disconnect" CLASS="connecting" else ON_CLICK="mullvad reconnect" CLASS="disconnected" fi echo '{"text":"'$TEXT'", "tooltip":"'$TOOLTIP'", "class":"'$CLASS'"}'