Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Network module WiFi signal strength issues #2179

Open
RouNNdeL opened this issue Sep 6, 2020 · 2 comments
Open

Network module WiFi signal strength issues #2179

RouNNdeL opened this issue Sep 6, 2020 · 2 comments
Labels

Comments

@RouNNdeL
Copy link

@RouNNdeL RouNNdeL commented Sep 6, 2020

Describe the issue

I'm using the internal/network module. The signal value changes unpredictably and does not follow the set interval.

Expected behavior:
The value should update every 2s - interval = 2. The value should scale roughly between 0-100.

Actual behavior:
I was not able to consistently measure how often the value updates (walking around the house, to keep change the signal strength). Sometimes It'd update every 15-30s , and sometimes it would get stuck for a few minutes. The value would never go above 42 even right next to the router, and never below 22 even on the edge of losing the signal.

EDIT: The value just updated to 47 (the highest ever seen) at -56 dBm.

Was it working before?
No, it's the first time I'm using polybar.

To Reproduce

[colors]
background = #70000000
foreground = #dfdfdf

[bar/bar]
width = 100%
height = 34
offset-x = 1%
offset-y = 1%

background = ${colors.background}
foreground = ${colors.foreground}

font-0 = "Roboto:style=Medium:pixelsize=11;2"
font-1 = "Roboto:style=Medium:pixelsize=8;2"
font-2 = "Symbols Nerd Font:fontformat=truetype:pixelsize=13;4"
font-3 = "Roboto:style=Bold:pixelsize=15;2"
font-4 = "Roboto:style=Medium:pixelsize=10;2"
font-5 = "Roboto:style=Bold:pixelsize=11;2"
font-6 = "Roboto:style=Regular:pixelsize=11;2"
font-7 = "Roboto:style=Thin:pixelsize=30;2"
font-8 = "Material Design Icons Desktop:fontformat=truetype:pixelsize=13;4"

modules-left = 
modules-center = 
modules-right = wlan

[module/wlan]
type = internal/network
interface = wlp0s20f3
interval = 2 

format-connected = <label-connected>
label-connected = %{T6}%essid% %{T7}%local_ip% %signal%
label-connected-foreground = #ff87c095

The value reported by iwconfig look good. Signal strength -20dBm - -75dBm.

Polybar Log

* Loading config: /home/kris/config_wifi_only
- config: Current bar section: [bar/bar]
* Loaded monitor eDP1 (1920x1080+0+0)
* Bar geometry: 1920x34+19+11; Borders: 0,0,0,0
- bar: Attach X event sink
- bar: Attach signal receiver
- controller: Install signal handler
- controller: Setup user-defined modules
* Starting application
- controller: Main thread id = 1
* Starting module/wlan
- module/wlan: Thread id = 2
* Entering event loop (thread-id=1)
- controller: Attach config watch
* Eventqueue worker (thread-id=3)
- bar: Create renderer
- renderer: Get TrueColor visual
- renderer: Allocate colormap
- renderer: Allocate output window
- renderer: Allocate window pixmaps
- renderer: Allocate graphic contexts
- renderer: Allocate alignment blocks
- renderer: Allocate cairo components
- renderer: Load fonts
* Configured DPI = 96x96
* Loaded font "Roboto:style=Medium:pixelsize=11" (name=Roboto, offset=2, file=/usr/share/fonts/TTF/Roboto-Medium.ttf)
* Loaded font "Roboto:style=Medium:pixelsize=8" (name=Roboto, offset=2, file=/usr/share/fonts/TTF/Roboto-Medium.ttf)
* Loaded font "Symbols Nerd Font:fontformat=truetype:pixelsize=13" (name=Symbols Nerd Font, offset=4, file=/usr/share/fonts/TTF/Symbols-2048-em Nerd Font Complete.ttf)
* Loaded font "Roboto:style=Bold:pixelsize=15" (name=Roboto, offset=2, file=/usr/share/fonts/TTF/Roboto-Bold.ttf)
* Loaded font "Roboto:style=Medium:pixelsize=10" (name=Roboto, offset=2, file=/usr/share/fonts/TTF/Roboto-Medium.ttf)
* Loaded font "Roboto:style=Bold:pixelsize=11" (name=Roboto, offset=2, file=/usr/share/fonts/TTF/Roboto-Bold.ttf)
* Loaded font "Roboto:style=Regular:pixelsize=11" (name=Roboto, offset=2, file=/usr/share/fonts/TTF/Roboto-Regular.ttf)
* Loaded font "Roboto:style=Thin:pixelsize=30" (name=Roboto, offset=2, file=/usr/share/fonts/TTF/Roboto-Thin.ttf)
* Loaded font "Material Design Icons Desktop:fontformat=truetype:pixelsize=13" (name=Material Design Icons Desktop, offset=4, file=/usr/share/fonts/MaterialDesignIconsDesktop.ttf)
* Bar window: 0x0e00001
- bar: Reconfigure window
- bar: Set window WM_NAME
- bar: Set window _NET_WM_WINDOW_TYPE
- bar: Set window _NET_WM_STATE
- bar: Set window _NET_WM_DESKTOP
- bar: Set window _NET_WM_PID
- bar: Map window
- bar: Draw empty bar
- bar: Setup tray manager
* Disabling tray manager (reason: missing `tray-position`)
* module/wlan: Rebuilding cache
- bar: Force update
* Redrawing bar window
- renderer: flush(3 geom=161x34+1759+0, falloff=0)
- bar: Received expose event
* module/wlan: Rebuilding cache
- bar: Ignoring update (unchanged)
* module/wlan: Rebuilding cache
- bar: Ignoring update (unchanged)
* module/wlan: Rebuilding cache
- bar: Ignoring update (unchanged)
* module/wlan: Rebuilding cache
- bar: Ignoring update (unchanged)
* module/wlan: Rebuilding cache
- bar: Ignoring update (unchanged)
* module/wlan: Rebuilding cache

When the value finally updates:

- bar: Ignoring update (unchanged)
* module/wlan: Rebuilding cache
* Redrawing bar window
- renderer: flush(3 geom=161x34+1759+0, falloff=0)
* module/wlan: Rebuilding cache
- bar: Ignoring update (unchanged)
* module/wlan: Rebuilding cache

Environment:

  • WM: i3
  • Distro: Arch
  • Output of polybar -vvv:
polybar 3.4.3

Features: +alsa +curl +i3 +mpd +network(libnl) +pulseaudio +xkeyboard

X extensions: +randr (+monitors) +composite +xkb +xrm +xcursor

Build type: Release
Compiler: /usr/bin/c++
Compiler flags: -D_FORTIFY_SOURCE=2 -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -Wall -Wextra -Wpedantic -O3 -DNDEBUG
Linker flags: -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now 

Additional context

Example output of iwconfig:

wlp0s20f3  IEEE 802.11  ESSID:"<SSID>"  
          Mode:Managed  Frequency:5.2 GHz  Access Point: <mac address>
          Bit Rate=780 Mb/s   Tx-Power=22 dBm   
          Retry short limit:7   RTS thr:off   Fragment thr:off
          Power Management:on
          Link Quality=57/70  Signal level=-53 dBm  
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:2  Invalid misc:2013   Missed beacon:0

@cynicated
Copy link

@cynicated cynicated commented Dec 6, 2020

@RouNNdeL - I'm not denying that there may be an issue here, but digging through the wireless-tools library, I'm not certain that this should be going from 0 - 100.

This is actually somewhat problematic to code as the idea of a maximum quality is a bit odd when talking about dB. I think the best option would be to display the actual dB instead of trying to create some form of percentage here.

@patrick96
Copy link
Member

@patrick96 patrick96 commented Apr 22, 2022

The values for %signal% do go from 0 to 100, but the edges (especially 100% is rarely reached). A signal strength of -20dBm coresponds to 100% and -90dBm is 0% with linear interpolation in between.

Many other tools use a quadratic formula that one of the drivers in the linux kernel uses and which reaches a higher percentage value earlier. One example for this is i3status-rust

There is probably a case to be made for polybar to adapt the same model because it would match what many other tools are already doing and values around -50dBm are already quite good and don't necessarily warant only a 57% signal strength.

PRs are welcome, but this really isn't critical.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants