From 29cbb903a5c2bf074b26e3c87c4cbb69793b3e19 Mon Sep 17 00:00:00 2001 From: Urbain Vaes Date: Fri, 3 Sep 2021 18:22:36 +0200 Subject: Fix i3 bugs --- i3/.config/i3blocks/bin/wifi | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'i3/.config/i3blocks/bin/wifi') diff --git a/i3/.config/i3blocks/bin/wifi b/i3/.config/i3blocks/bin/wifi index bc24672..b545c24 100755 --- a/i3/.config/i3blocks/bin/wifi +++ b/i3/.config/i3blocks/bin/wifi @@ -1,15 +1,16 @@ #!/usr/bin/env bash -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 ).*(?=/)") +wireless=$(ip link | grep -oP -m1 "(wlp[^:]*)") +quality=$(iwconfig $wireless 2>/dev/null | grep -oP 'Link Quality=\K[0-9]*/[0-9]*' | awk -F'/' '{print int(100*$1/$2)}') +ssid=$(iwconfig $wireless 2>/dev/null | grep -oP '(?<=ESSID:")[^\"]*') +wifi_address=$(ip addr show $wireless 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 full_text="eno1: $eth_address" ip_addr="$eth_address" elif [[ -n $wifi_address ]]; then - full_text="wlp2s0: (${quality}% at ${ssid}) ${wifi_address}" + full_text="${wifi_address} (${quality}% at ${ssid})" ip_addr="$wifi_address" else echo "No connection" -- cgit v1.2.3