From 79202a934d0ba9f08938b638be5ae32283bf8f2b Mon Sep 17 00:00:00 2001 From: Dustin Kirkland Date: Sat, 1 Jun 2019 16:12:18 -0500 Subject: [PATCH] * usr/lib/byobu/wifi_quality: - prefer iwconfig over iw for now, iw is not working for me --- debian/changelog | 2 ++ usr/lib/byobu/wifi_quality | 26 +++++++++++++------------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/debian/changelog b/debian/changelog index 49a8eccd..592ca083 100644 --- a/debian/changelog +++ b/debian/changelog @@ -18,6 +18,8 @@ byobu (5.128) unreleased; urgency=medium commands when going back by history. All colors in command prompt should be escaped with [ ] - https://github.com/dustinkirkland/byobu/pull/30 + * usr/lib/byobu/wifi_quality: + - prefer iwconfig over iw for now, iw is not working for me [ Jeffery To ] * usr/bin/byobu-disable-prompt.in, diff --git a/usr/lib/byobu/wifi_quality b/usr/lib/byobu/wifi_quality index 5b687c0e..18aedf7b 100755 --- a/usr/lib/byobu/wifi_quality +++ b/usr/lib/byobu/wifi_quality @@ -42,7 +42,19 @@ __wifi_quality_detail() { __wifi_quality() { local out bitrate quality - if eval $BYOBU_TEST iw >/dev/null 2>&1; then + if eval $BYOBU_TEST iwconfig >/dev/null 2>&1; then + # iwconfig is expected to output lines like: + # Bit Rate=54 Mb/s Tx-Power=15 dBm + # Link Quality=60/70 Signal level=-50 dBm + # the awk below tokenizes the output and prints shell evalable results + out=`iwconfig $MONITORED_NETWORK 2>/dev/null | + awk '$0 ~ /[ ]*Link Quality./ { + sub(/.*=/,"",$2); split($2,a,"/"); + printf "quality=%.0f\n", 100*a[1]/a[2] }; + $0 ~ /[ ]*Bit Rate/ { sub(/.*[:=]/,"",$2); printf("bitrate=%s\n", $2); } + '` + eval "$out" + elif eval $BYOBU_TEST iw >/dev/null 2>&1; then local dev for dev in $(___get_dev_list); do # iw is expected to output lines like: @@ -57,18 +69,6 @@ __wifi_quality() { eval "$out" [ -z "$bitrate" ] || [ -z "$quality" ] || break done - elif eval $BYOBU_TEST iwconfig >/dev/null 2>&1; then - # iwconfig is expected to output lines like: - # Bit Rate=54 Mb/s Tx-Power=15 dBm - # Link Quality=60/70 Signal level=-50 dBm - # the awk below tokenizes the output and prints shell evalable results - out=`iwconfig $MONITORED_NETWORK 2>/dev/null | - awk '$0 ~ /[ ]*Link Quality./ { - sub(/.*=/,"",$2); split($2,a,"/"); - printf "quality=%.0f\n", 100*a[1]/a[2] }; - $0 ~ /[ ]*Bit Rate/ { sub(/.*[:=]/,"",$2); printf("bitrate=%s\n", $2); } - '` - eval "$out" fi [ -n "$bitrate" ] || bitrate=0 [ -n "$quality" ] || quality=0