Skip to content

Commit

Permalink
chore: update system_stats and thiserror
Browse files Browse the repository at this point in the history
it seems sensible to remove not listed interfaces when refreshing, so that's what was
chosen here.
  • Loading branch information
w-lfchen committed Dec 29, 2024
1 parent 39f1380 commit e76583e
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 21 deletions.
42 changes: 31 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ smart-default = "0.7.1"
static_assertions = "1.1.0"
strsim = "0.11"
strum = { version = "0.26", features = ["derive"] }
sysinfo = "0.31.2"
thiserror = "1.0"
sysinfo = "0.33.1"
thiserror = "2.0.0"
tokio-util = "0.7.11"
tokio = { version = "1.39.2", features = ["full"] }
unescaper = "0.1"
Expand Down
13 changes: 5 additions & 8 deletions crates/eww/src/config/system_stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ static NETWORKS: Lazy<Mutex<(RefreshTime, sysinfo::Networks)>> =

pub fn get_disks() -> String {
let mut disks = DISKS.lock().unwrap();
disks.refresh_list();
disks.refresh();
disks.refresh(true);

disks
.iter()
Expand Down Expand Up @@ -72,16 +71,14 @@ pub fn get_ram() -> String {

pub fn get_temperatures() -> String {
let mut components = COMPONENTS.lock().unwrap();
components.refresh_list();
components.refresh();
components.refresh(true);
components
.iter()
.map(|c| {
(
c.label().to_uppercase().replace(' ', "_"),
// It is common for temperatures to report a non-numeric value.
// Tolerate it by serializing it as the string "null"
c.temperature().to_string().replace("NaN", "\"null\""),
// if the temperature couldn't be fetched, serialize it as "null"
c.temperature().map_or_else(|| String::from("\"null\""), |temp| temp.to_string()),
)
})
.collect::<serde_json::Value>()
Expand Down Expand Up @@ -257,7 +254,7 @@ pub fn get_battery_capacity() -> Result<String> {
pub fn net() -> String {
let (ref mut last_refresh, ref mut networks) = &mut *NETWORKS.lock().unwrap();

networks.refresh_list();
networks.refresh(true);
let elapsed = last_refresh.next_refresh();

networks
Expand Down

0 comments on commit e76583e

Please sign in to comment.