From a2d8e3bf021c7a060034949d1c06b99b01e4d117 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs?= Date: Tue, 1 Oct 2019 12:30:14 -0500 Subject: [PATCH] Detect IP VPN if is enabled --- scripts/i3blocks/iface | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/i3blocks/iface b/scripts/i3blocks/iface index dae871c..af36bfe 100755 --- a/scripts/i3blocks/iface +++ b/scripts/i3blocks/iface @@ -49,8 +49,12 @@ case $1 in AF=inet6? ;; esac -# if no interface is found, use the first device with a global scope -IPADDR=$(ip addr show "$IF" | perl -n -e "/$AF ([^\/]+).* scope global/ && print \$1 and exit") +# look for the vpn connection, if no interface is found, use the first device with a global scope +if [[ $(ip addr show tun0) ]]; then + IPADDR=$(ip addr show tun0 | awk '/inet.*brd/ {print $2}' | awk -F'/' '{print $1}') +else + IPADDR=$(ip addr show "$IF" | perl -n -e "/$AF ([^\/]+).* scope global/ && print \$1 and exit") +fi case $BLOCK_BUTTON in 3) echo -n "$IPADDR" | xclip -q -se c ;;