aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesús <heckyel@hyperbola.info>2019-10-01 12:30:14 -0500
committerJesús <heckyel@hyperbola.info>2019-10-01 12:30:14 -0500
commita2d8e3bf021c7a060034949d1c06b99b01e4d117 (patch)
tree8d4f7f763685b50e1c35a87a5fb732dd30d69723
parent141b9a8f30a247e111170c3f5d53251aab5a3877 (diff)
downloadi3-config-a2d8e3bf021c7a060034949d1c06b99b01e4d117.tar.lz
i3-config-a2d8e3bf021c7a060034949d1c06b99b01e4d117.tar.xz
i3-config-a2d8e3bf021c7a060034949d1c06b99b01e4d117.zip
Detect IP VPN if is enabled
-rwxr-xr-xscripts/i3blocks/iface8
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 ;;