aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesús <heckyel@hyperbola.info>2020-01-25 13:35:09 -0500
committerJesús <heckyel@hyperbola.info>2020-01-25 13:35:09 -0500
commit6538c520806bfd13d8009b00b22a05132404d2aa (patch)
treea7da854618ddb8859bc2218bc78731ba2f202db7
parenta1ac296557f5204c66206d1057a7f53dc6187b79 (diff)
downloadi3-config-6538c520806bfd13d8009b00b22a05132404d2aa.tar.lz
i3-config-6538c520806bfd13d8009b00b22a05132404d2aa.tar.xz
i3-config-6538c520806bfd13d8009b00b22a05132404d2aa.zip
always ip
-rwxr-xr-xscripts/i3blocks/iface24
1 files changed, 7 insertions, 17 deletions
diff --git a/scripts/i3blocks/iface b/scripts/i3blocks/iface
index da0145a..46e78bc 100755
--- a/scripts/i3blocks/iface
+++ b/scripts/i3blocks/iface
@@ -1,7 +1,7 @@
#!/bin/bash
# Copyright (C) 2014 Julien Bonjean <julien@bonjean.info>
# Copyright (C) 2014 Alexander Keller <github@nycroth.com>
-# Copyright (C) 2019 Jesús E. <heckyel@hyperbola.info>
+# Copyright (C) 2020 Jesús E. <heckyel@hyperbola.info>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -33,15 +33,10 @@ IF="${IF:-$(ip route | awk '/^default/ { print $5 ; exit }')}"
#------------------------------------------------------------------------
-AF=${ADDRESS_FAMILY:-inet6?}
LABEL="${LABEL:-}"
for flag in "$1" "$2"; do
case "$flag" in
- -4)
- AF=inet ;;
- -6)
- AF=inet6 ;;
-L)
if [[ "$IF" = "" ]]; then
LABEL="iface "
@@ -51,19 +46,15 @@ for flag in "$1" "$2"; do
esac
done
-if [[ "$IF" = "" ]] || [[ "$(cat "/sys/class/net/$IF/operstate")" = 'down' ]]; then
- echo "${LABEL}down" # full text
- echo "${LABEL}down" # short text
+if [[ "$IF" = "" ]] || [[ "$(cat "/sys/class/net/$IF/operstate")" = 'down' ]];
+then
+ echo "${LABEL}down" # text
echo \#FF0000 # color
exit
fi
-# 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
+# Check local ip address
+IPADDR=$(ip route get 4.2.2.1 | awk '{print $NF;exit}')
case $BLOCK_BUTTON in
3) echo -n "$IPADDR" | xclip -q -se c ;;
@@ -71,5 +62,4 @@ esac
#------------------------------------------------------------------------
-echo "$LABEL$IPADDR" # full text
-echo "$LABEL$IPADDR" # short text
+echo "$LABEL$IPADDR"