Wifi signalStrength is inaccurate
Hi, I recently switched to Sway and shortly after that I started using Waybar 0.9.1. First: Thank you for this cool project! I really enjoy it.
I have just one issue. The "signalStrength" value does not reflect the real signal strength of my wifi connection. Even when setting a fixed interface in the config. At this moment Waybar reports a signal strength of 38% while sitting very close to the ap. While nmcli dev wifi reports 94%. The issue stays when connecting to other ap's.
Here's my network config:
"network": {
"interface": "wlp0s20f3",
"interval": 10,
"format-wifi": " {essid} ({signalStrength}%)", // Icon: wifi
"format-ethernet": " {ifname}: {ipaddr}/{cidr}", // Icon: ethernet
"format-disconnected": "⚠ Disconnected",
"tooltip-format": "{ifname}: {ipaddr}"
},
Wifi adapter: Killer Wi-Fi 6 AX1650i 160MHz Wireless Network Adapter (201NGW).
It seems that the signal strength is only updated when wpa_supplicant preforms a scan for near by networks. The quickest way to enable background network scanning for wpa_supplicant is through the wpa_cli. Here is the command I used (with the interface changed to yours):
wpa_cli -i wlp0s20f3 <<EOF
scan_interval set 10 # sets the background network scanning to once every 10 seconds
save_config # appends the new setting to the config
quit # quits out of wpa_cli
EOF
Note: For this command to take effect, you might need to run it as root unless you have explicit privilege to change network config (using user groups like network or systemd-network).
If the command line approach doesn't work, you can add the following line to your wpa_supplicant config file in /etc/wpa_supplicant.conf or /etc/wpa_supplicant/*.conf.
bgscan="simple:10:-35:300"
@asteinba Hope this helps!
@dorgnarg if I'm not mistaken, your potential fix seeks to alter the mapping between signal strength in dBm and signal strength in percentage points. If I understand correctly, the issue here is that the signal strength is not being updated, or at least not regularly enough, which is what @Geo25rey 's suggestion tries to workaround.
From my understanding then, your PR does not resolve the issue, and rather changes something that currently works: if I sit next to my AP and trigger a scan with wpa_cli, I get an acceptable signal strength reported by the waybar network module.
I believe the solution to this bug is either
- include in the Wiki that for the waybar network module to work, wpa_supplicant must be configured so that background scans occur regularly (which is essentially what @Geo25rey 's workaround accomplishes), or
- make the waybar network module trigger network scans, and require the user to acquire sufficient privileges for this.
I'm inclined to say the latter is a better solution, since it's less intrusive and is probably more network service agnostic. I use netctl and I believe netctl overrides the configuration of wpa_supplicant, so any changes to it to enable regular scanning will be ignored.
I noticed this bug for me. Waybar shows signal strength as 46%, while all other interfaces are 100%
After disconnect-connect to WIfi it shows 60%, and nmcli dev wifi reports 92%
So it seems the signal strength is updated, but it still inaccurate.
Here is my config:
"network": {
"format-wifi": "{essid} ({signalStrength}%) ",
"format-ethernet": "{ipaddr}/{cidr} ",
"tooltip-format": "{ifname} via {gwaddr} ",
"format-linked": "{ifname} (No IP) ",
"format-disconnected": "Disconnected ⚠",
"format-alt": "{ifname}: {ipaddr}/{cidr}"
},
Also noticed this on 0.10.4. I tried to use a simple custom module extracting info from iwconfig along Waybar' own network module, and my script consistently returns exactly double the value of what original module indicates. Maybe formula used to calculate signal strength has some error?
The command I'm using was shamelessly stolen from here:
https://stackoverflow.com/questions/54833789/get-signal-quality-in-from-iwconfig
Confirm this issue (Waybar v0.11.0, MT-7601 USB WI-FI dongle, Arch Linux)
Waybar shows values between (46-68%). When iwconfig or nmcli dev wifi show perfect link quality
IN-USE BSSID SSID MODE CHAN RATE SIGNAL BARS SECURITY
* XX:XX:XX:XX:XX:XX AndroidAP Infra 6 117 Mbit/s 99 ▂▄▆█ WPA2
wlan0 IEEE 802.11 ESSID:"AndroidAP"
Bit Rate=72.2 Mb/s Tx-Power=20 dBm
Retry short limit:7 RTS thr:off Fragment thr:off
Power Management:off
Link Quality=70/70 Signal level=-23 dBm
Larse RSSI values displaying less signal strength seems to be intentional (was added in #1353):
https://github.com/Alexays/Waybar/blob/52d582b93ad37f216df4eebe4cac40fb86852778/src/modules/network.cpp#L806-L815
(Although I think it's kind of poor UX still. It also feels that in most cases -23 51% should be better than -67 51%.)
For comparison, networkmanager's implementation is in nm-wifi-utils-wext.c and nm-wifi-utils-nl80211.c