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

Fixes #387: Display WiFi signal strength in the net block #418

Merged
merged 1 commit into from Aug 14, 2019

Conversation

bnjbvr
Copy link
Contributor

@bnjbvr bnjbvr commented Aug 8, 2019

Hi! I wanted to see the Wifi signal strength in the status bar, and saw there was an open issue with some hints to do it. Turns out that iw provides this information too, so we can parse its output to figure it out. It's a bit inefficient because we may call iw several times to grep for some of its information, but I think it's fine since it doesn't happen a lot.

I've reused the formulas hinted at in the issue, and I can confirm they coincide with the results provided by the original i3status bar on my machine.

Copy link
Contributor

@SWW13 SWW13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, thanks :)

Besides the copied error message the code LGTM and works on my machine.


It's a bit inefficient because we may call iw several times to grep for some of its information, but I think it's fine since it doesn't happen a lot.

That's already the case for SSID and bitrate, I think it's fine to leave that up to a future refactoring. The there could be only one execution of iw for all of them. That would also save the execution of sh and sed, but require more parsing in our code.

src/blocks/net.rs Outdated Show resolved Hide resolved
@atheriel atheriel merged commit 857aaff into greshake:master Aug 14, 2019
@atheriel
Copy link
Collaborator

Thanks!

@rsteube
Copy link
Contributor

rsteube commented Aug 14, 2019

Oh nice, it's already in.
@bnjbvr i'm getting command failed: Operation not permitted (-1) for the iw dev .. link command - am i missing a group or is a sudo entry necessary?

(fyi: network-manager gives out bars like ▂▄▆_ with: `nmcli device wifi list | grep '^*' | awk '{print $8}' )

@bnjbvr bnjbvr deleted the signal-strength branch August 15, 2019 08:12
@bnjbvr
Copy link
Contributor Author

bnjbvr commented Aug 15, 2019

@rsteube I have honestly no clues regarding the issue; a quick search seems to tell it could be a driver issue.

Regarding the nmcli line: it also contains the relative signal strength (under the SIGNAL column), so we could directly copy it out from there. Nice thing is that it displays the same value as my code :) (which is obvious, since the code I added is copied from network-manager's...)

@rsteube
Copy link
Contributor

rsteube commented Aug 15, 2019

Yes would be nice to have nmcli as option since it seems iw won't work without sudo on some systems.
This looks great for parsing: nmcli -t -f in-use,active,ssid,signal dev wifi:

nmcli -t -f in-use,active,ssid,signal dev wifi
 :no:guestnet:80
 :no:skynet:79
*:yes:skynet:66

(only works if network-manager is used though)

@rsteube
Copy link
Contributor

rsteube commented Aug 15, 2019

@BenFradet
Copy link

weird thing, building from master I'm getting:

{"version": 1, "click_events": true}
[[{"background":"#000000","color":"#dc322f","full_text":" Configuration error: failed to deserialize block config.\nCause: unknown field `signal_strength`, expected one of `interval`, `device`, `ssid`, `max_ssid_width`, `bitrate`, `ip`, `hide_inactive`, `hide_missing`, `speed_up`, `speed_down`, `graph_up`, `graph_down`, `on_click` ","separator":false,"separator_block_width":0}]


Configuration error: failed to deserialize block config.
Cause: unknown field `signal_strength`, expected one of `interval`, `device`, `ssid`, `max_ssid_width`, `bitrate`, `ip`, `hide_inactive`, `hide_missing`, `speed_up`, `speed_down`, `graph_up`, `graph_down`, `on_click`
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: "SendError(..)"', src/libcore/result.rs:999:5

when building from 374e709

@BenFradet
Copy link

nvm, the wrong artifact was picked up appreantly

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

Successfully merging this pull request may close these issues.

None yet

5 participants