Improve efficiency of Nordvpn polybar status
This commit is contained in:
parent
c5a22c5585
commit
28a139b5c7
@ -491,11 +491,9 @@
|
|||||||
:header-args+: :shebang "#!/usr/bin/env bash"
|
:header-args+: :shebang "#!/usr/bin/env bash"
|
||||||
:END:
|
:END:
|
||||||
#+BEGIN_SRC bash
|
#+BEGIN_SRC bash
|
||||||
vpnstatus=`nordvpn status`;
|
tmpfile="/tmp/vpnstatus";
|
||||||
|
|
||||||
if [[ ${vpnstatus} == *"Connected"* ]]; then
|
if [ -f $tmpfile ] && grep -q "on" $tmpfile; then
|
||||||
# country=`nordvpn status | sed '/Country/!d ; s/Country: //'`
|
|
||||||
# echo "%{F#859900}%{F-} $country";
|
|
||||||
echo "%{F#859900}%{F-}";
|
echo "%{F#859900}%{F-}";
|
||||||
else
|
else
|
||||||
echo "";
|
echo "";
|
||||||
@ -509,12 +507,14 @@
|
|||||||
:header-args+: :shebang "#!/usr/bin/env bash"
|
:header-args+: :shebang "#!/usr/bin/env bash"
|
||||||
:END:
|
:END:
|
||||||
#+BEGIN_SRC bash
|
#+BEGIN_SRC bash
|
||||||
if [[ $(nordvpn status) == *"Connected"* ]]; then
|
tmpfile="/tmp/vpnstatus";
|
||||||
nordvpn disconnect && dunstify --replace=23198 "VPN" "Disconnected";
|
|
||||||
|
if [ -f $tmpfile ] && grep -q "on" $tmpfile; then
|
||||||
|
nordvpn disconnect && dunstify --replace=23198 "VPN" "Disconnected" && echo "off" > $tmpfile;
|
||||||
else
|
else
|
||||||
country=`cat ~/bin/nordvpn_countries.txt | sed 's/\s*\t\s*/ /g ; s/\s/\n/g ; s/_/ /g ; /^[a-zA-Z]/!d ; s/\(.*\)/\L\1/' | rofi -i -dmenu | sed 's/\s/_/g'`;
|
country=`cat ~/bin/nordvpn_countries.txt | sed 's/\s*\t\s*/ /g ; s/\s/\n/g ; s/_/ /g ; /^[a-zA-Z]/!d ; s/\(.*\)/\L\1/' | rofi -i -dmenu | sed 's/\s/_/g'`;
|
||||||
dunstify --replace=23198 "VPN" "Connecting to $country...";
|
dunstify --replace=23198 "VPN" "Connecting to $country...";
|
||||||
nordvpn connect $country && dunstify --replace=23198 "VPN" "Connected to $country";
|
nordvpn connect $country && dunstify --replace=23198 "VPN" "Connected to $country" && echo "on" > $tmpfile;
|
||||||
fi
|
fi
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user