Fix: EWW_NET wrong values for TX/RX stats (#1108)

* Fix: EWW_NET wrong values for TX/RX stats

The sysinfo crate, structure Networks, basically caches one value of
total_received/total_transmitted each (as well as other metrics) and
returns the difference between those two values when queried via the
`received()` and `transmitted()` functions.

These values are updated by both the `refresh()` and `refresh_list()`
functions; so by calling both of them right after each other like
previously done here, sets both the cached total_received/... and the
current total_received/... to nearly the same value.

`refresh_list()` also updates the list of interfaces on a host, with a
marginally small performance impact for doing so (I measured slightly
more than 100 microseconds on my machine (0.1 milliseconds), around
20-25% more than with `refresh()`), especially considering this is run
only every 2 seconds.

* Add changelog entry for the EWW_NET bugfix
This commit is contained in:
mario-kr 2024-08-25 15:45:33 +02:00 committed by GitHub
parent 6b6e236e2e
commit fefba66ff5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 1 additions and 1 deletions

View file

@ -9,6 +9,7 @@ All notable changes to eww will be listed here, starting at changes since versio
- Fix and refactor nix flake (By: w-lfchen)
- Fix remove items from systray (By: vnva)
- Fix the gtk `stack` widget (By: ovalkonia)
- Fix values in the `EWW_NET` variable (By: mario-kr)
### Features
- Update rust toolchain to 1.80.1 (By: w-lfchen)

View file

@ -212,7 +212,6 @@ pub fn net() -> String {
let (ref mut last_refresh, ref mut networks) = &mut *NETWORKS.lock().unwrap();
networks.refresh_list();
networks.refresh();
let elapsed = last_refresh.next_refresh();
networks