* usr/lib/byobu/wifi_quality:

- prefer iwconfig over iw for now, iw is not working for me
This commit is contained in:
Dustin Kirkland 2019-06-01 16:12:18 -05:00
commit 79202a934d
2 changed files with 15 additions and 13 deletions

2
debian/changelog vendored
View file

@ -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,

View file

@ -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