diff options
author | Urbain Vaes <urbain@vaes.uk> | 2018-01-31 12:16:32 +0000 |
---|---|---|
committer | Urbain Vaes <urbain@vaes.uk> | 2018-01-31 12:16:32 +0000 |
commit | 3d4dc46d3f39edacf3654ba00a666383a12d8375 (patch) | |
tree | 35224cc1b46a8c6c0cfb310aafabf5c3ac1319ec | |
parent | 0a0acf361b779ac7346e2bd5ac7156b42d376166 (diff) |
[i3blocks] Update wifi block
-rwxr-xr-x | i3/.config/i3blocks/bin/wifi | 16 | ||||
-rw-r--r-- | i3/.config/i3blocks/config | 4 |
2 files changed, 14 insertions, 6 deletions
diff --git a/i3/.config/i3blocks/bin/wifi b/i3/.config/i3blocks/bin/wifi index fd9a9c5..01ff021 100755 --- a/i3/.config/i3blocks/bin/wifi +++ b/i3/.config/i3blocks/bin/wifi @@ -1,7 +1,15 @@ #!/usr/bin/env bash -quality=$(iwconfig wlp2s0 | grep -oP 'Link Quality=\K[0-9]*/[0-9]*' | awk -F'/' '{print int(100*$1/$2)}') -ssid=$(iwconfig wlp2s0 | grep -oP '(?<=ESSID:").*(?=")') -address=$(ip addr show wlp2s0 | grep -oP -m1 "(?<=inet ).*(?=/)") +quality=$(iwconfig wlp2s0 2>/dev/null | grep -oP 'Link Quality=\K[0-9]*/[0-9]*' | awk -F'/' '{print int(100*$1/$2)}') +ssid=$(iwconfig wlp2s0 2>/dev/null | grep -oP '(?<=ESSID:").*(?=")') +wifi_address=$(ip addr show wlp2s0 2>/dev/null | grep -oP -m1 "(?<=inet ).*(?=/)") +eth_address=$(ip addr show eno1 2>/dev/null | grep -oP -m1 "(?<=inet ).*(?=/)") + +if [[ -n $eth_address ]]; then + echo "eno1: $eth_address" +elif [[ -n $wifi_address ]]; then + echo "wlp2s0: (${quality}% at ${ssid}) ${address}" +else + echo "No connection" +fi -echo "(${quality}% at ${ssid}) ${address}" diff --git a/i3/.config/i3blocks/config b/i3/.config/i3blocks/config index af4d658..2e149bf 100644 --- a/i3/.config/i3blocks/config +++ b/i3/.config/i3blocks/config @@ -39,13 +39,13 @@ label=♪ instance=Master interval=5 -[email] +[wifi] label=W: command=~/dotfiles/i3/.config/i3blocks/bin/wifi separator=true interval=5 -[wifi] +[email] label=Mail: command=~/dotfiles/i3/.config/i3blocks/bin/email separator=true |