diff options
-rwxr-xr-x | scripts/i3blocks/iface | 8 |
1 files 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 ;; |