diff --git a/toggle-mozvpn.sh b/toggle-mozvpn.sh index eb2e586..827d91a 100644 --- a/toggle-mozvpn.sh +++ b/toggle-mozvpn.sh @@ -1,14 +1,22 @@ #!/bin/bash STATE=$(mozillavpn status | grep "VPN state" | awk '{print $3}') - +LOCATION=$(mozillavpn status | grep "Server city" | awk '{print $3}') if [ "$STATE" == "off" ]; then - mozillavpn activate - notify-send -i /usr/share/icons/hicolor/32x32/apps/mozillavpn.png "Mozilla VPN" "VPN Activated" + FEEDBACK=$(mozillavpn activate) + if [[ $FEEDBACK == *"The VPN tunnel is now active"* ]]; then + notify-send -i /usr/share/icons/hicolor/32x32/apps/mozillavpn.png "Mozilla VPN" "VPN Activated: $LOCATION" + else + notify-send --urgency=critical -i /usr/share/icons/hicolor/32x32/apps/mozillavpn.png "Mozilla VPN" "Error" + fi fi if [ "$STATE" == "on" ]; then - mozillavpn deactivate - notify-send -i /usr/share/icons/hicolor/32x32/apps/mozillavpn.png "Mozilla VPN" "VPN Deactivated" + FEEDBACK=$(mozillavpn deactivate) + if [[ $FEEDBACK == *"The VPN tunnel is now inactive"* ]]; then + notify-send -i /usr/share/icons/hicolor/32x32/apps/mozillavpn.png "Mozilla VPN" "VPN Deactivated" + else + notify-send --urgency=critical -i /usr/share/icons/hicolor/32x32/apps/mozillavpn.png "Mozilla VPN" "Error" + fi fi