diff options
author | Karel Kočí <cynerd@email.cz> | 2017-03-01 10:51:32 +0100 |
---|---|---|
committer | Karel Kočí <cynerd@email.cz> | 2017-03-01 10:51:32 +0100 |
commit | 0b7760fd7cf2dafb33208a9a834282a4dc7ce0dd (patch) | |
tree | bd85afe4e9f278e616021d8797281d51f0b723d0 /config/i3blocks/scripts/iface | |
parent | 367320e729a769619a66ee4dc258cc1412b8548a (diff) | |
download | myconfigs-0b7760fd7cf2dafb33208a9a834282a4dc7ce0dd.tar.gz myconfigs-0b7760fd7cf2dafb33208a9a834282a4dc7ce0dd.tar.bz2 myconfigs-0b7760fd7cf2dafb33208a9a834282a4dc7ce0dd.zip |
Chnages in i3block scripts
Diffstat (limited to 'config/i3blocks/scripts/iface')
-rwxr-xr-x | config/i3blocks/scripts/iface | 34 |
1 files changed, 12 insertions, 22 deletions
diff --git a/config/i3blocks/scripts/iface b/config/i3blocks/scripts/iface index 7e6ac50..a0a1946 100755 --- a/config/i3blocks/scripts/iface +++ b/config/i3blocks/scripts/iface @@ -17,19 +17,9 @@ #------------------------------------------------------------------------ -# Locate current default interface -D_IF=$(ip route | awk '/^default/ { print $5 ; exit }') -# Filter if it's one of chosen ones -if [[ -n $BLOCK_INSTANCE ]]; then - for INT in $BLOCK_INSTANCE; do - if [ "$INT" = "$D_IF" ]; then - IF="$D_IF" - break - fi - done -else - IF="$D_IF" -fi +# Locate current default interface, but use only wlp (wifi) or enp (ethernet) +# TODO probably also add connection over phone +IF=$(ip route | awk '/^default .* (wlp|enp)/ { print $5 ; exit }') #------------------------------------------------------------------------ @@ -40,7 +30,7 @@ fi #------------------------------------------------------------------------ -# If no IF is selected then we want se down not anything else. +# If no IF is selected then we want see down, not anything else. if [ -z "$IF" ] || [[ "$(cat /sys/class/net/$IF/operstate)" = 'down' ]]; then echo down # full text echo down # short text @@ -49,19 +39,19 @@ if [ -z "$IF" ] || [[ "$(cat /sys/class/net/$IF/operstate)" = 'down' ]]; then fi case $1 in - -4) - AF=inet ;; - -6) - AF=inet6 ;; - *) - AF=inet6? ;; + -4) + AF=inet ;; + -6) + AF=inet6 ;; + *) + AF=inet6? ;; esac # Use the first global scope address IPADDR=$(ip addr show $IF | perl -n -e "/$AF ([^\/]+).* scope global/ && print \$1 and exit") case $BLOCK_BUTTON in - 3) echo -n "$IPADDR" | xclip -q -se c ;; + 3) echo -n "$IPADDR" | xclip -q -se c ;; esac #------------------------------------------------------------------------ @@ -70,7 +60,7 @@ echo "$IPADDR" # full text echo "$IPADDR" # short text #------------------------------------------------------------------------ -# Use fast ping to check if we have connection +# Use ping to check if we have connection # We ping only once and wait for one second PINGV="-c 1 -w 1" |