From 162ed8889b9893b790ca529e564d976f8190e3f3 Mon Sep 17 00:00:00 2001 From: Future is FOSS <79040025+futureisfoss@users.noreply.github.com> Date: Mon, 27 Sep 2021 19:18:53 +0530 Subject: [PATCH] fix sb-internet problems with multiple wifi cards (#1008) --- .local/bin/statusbar/sb-internet | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.local/bin/statusbar/sb-internet b/.local/bin/statusbar/sb-internet index d3948d7..94b7da2 100755 --- a/.local/bin/statusbar/sb-internet +++ b/.local/bin/statusbar/sb-internet @@ -17,9 +17,10 @@ case $BLOCK_BUTTON in 6) "$TERMINAL" -e "$EDITOR" "$0" ;; esac -case "$(cat /sys/class/net/w*/operstate 2>/dev/null)" in - down) [ "$(cat /sys/class/net/w*/flags)" = "0x1002" ] && wifiicon="❌ " || wifiicon="📡 " ;; - up) wifiicon="$(awk '/^\s*w/ { print "📶", int($3 * 100 / 70) "% " }' /proc/net/wireless)" ;; -esac +if grep -xq 'up' /sys/class/net/w*/operstate 2>/dev/null ; then + wifiicon="$(awk '/^\s*w/ { print "📶", int($3 * 100 / 70) "% " }' /proc/net/wireless)" +elif grep -xq 'down' /sys/class/net/w*/operstate 2>/dev/null ; then + grep -xq '0x1003' /sys/class/net/w*/flags && wifiicon="📡 " || wifiicon="❌ " +fi printf "%s%s%s\n" "$wifiicon" "$(sed "s/down/❎/;s/up/🌐/" /sys/class/net/e*/operstate 2>/dev/null)" "$(sed "s/.*/🔒/" /sys/class/net/tun*/operstate 2>/dev/null)"