From 4d383e4715e7789430d09756faaee3357facac6e Mon Sep 17 00:00:00 2001 From: srdusr Date: Thu, 8 Feb 2024 23:55:38 +0200 Subject: Show default icon and status --- .config/polybar/scripts/vpn.sh | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to '.config/polybar/scripts/vpn.sh') diff --git a/.config/polybar/scripts/vpn.sh b/.config/polybar/scripts/vpn.sh index 27def8a..ab1eb9d 100755 --- a/.config/polybar/scripts/vpn.sh +++ b/.config/polybar/scripts/vpn.sh @@ -1,13 +1,21 @@ #!/bin/sh -country=$(protonvpn s | grep Country) -connection=$(pgrep -a openvpn$ | head -n 1 | awk '{print $NF }' | cut -d '.' -f 1) +# Set a default message +default_message=" vpn" -if [ "$connection" != "" ]; then +# Check if Protonvpn service is running +if pgrep -x "openvpn" >/dev/null; then + # If Protonvpn service is running, get the country + country=$(protonvpn s | grep Country) + # Extract the connection ID + connection=$(pgrep -a openvpn$ | head -n 1 | awk '{print $NF }' | cut -d '.' -f 1) + # Output vpn status with the country if connected echo " vpn" #"$country" else - echo " vpn" + # If Protonvpn service is not running, output default message + echo "$default_message" fi + # #proton_status=$(protonvpn s) #current_status=$(protonvpn s | wc -l) -- cgit v1.2.3