diff --git a/Cargo.lock b/Cargo.lock index 2a3b80c..9ae7ab9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -355,12 +355,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "doc-comment" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" - [[package]] name = "dtoa" version = "0.4.8" @@ -1210,9 +1204,9 @@ checksum = "db13adb97ab515a3691f56e4dbab09283d0b86cb45abd991d8634a9d6f501760" [[package]] name = "libc" -version = "0.2.106" +version = "0.2.124" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a60553f9a9e039a333b4e9b20573b9e9b9c0bb3a11e201ccc48ef4283456d673" +checksum = "21a41fed9d98f27ab1c6d161da622a4fa35e8a54a8adc24bbf3ddd0ef70b0e50" [[package]] name = "linked-hash-map" @@ -2081,13 +2075,12 @@ dependencies = [ [[package]] name = "sysinfo" -version = "0.16.5" +version = "0.23.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567e910ef0207be81a4e1bb0491e9a8d9866cf45b20fe1a52c03d347da9ea51b" +checksum = "56b1e20ee77901236c389ff74618a899ff5fd34719a7ff0fd1d64f0acca5179a" dependencies = [ "cfg-if", "core-foundation-sys", - "doc-comment", "libc", "ntapi", "once_cell", diff --git a/crates/eww/Cargo.toml b/crates/eww/Cargo.toml index 0388f5c..932aa51 100644 --- a/crates/eww/Cargo.toml +++ b/crates/eww/Cargo.toml @@ -58,7 +58,7 @@ futures-core = "0.3" futures-util = "0.3" tokio-util = "0.6" -sysinfo = "0.16.1" +sysinfo = "0.23" dyn-clone = "1.0" wait-timeout = "0.2" diff --git a/crates/eww/src/config/system_stats.rs b/crates/eww/src/config/system_stats.rs index 7222fd7..5d39ffc 100644 --- a/crates/eww/src/config/system_stats.rs +++ b/crates/eww/src/config/system_stats.rs @@ -13,16 +13,16 @@ pub fn get_disks() -> String { format!( "{{ {} }}", - c.get_disks() + c.disks() .iter() .map(|c| { - let total_space = c.get_total_space(); - let available_space = c.get_available_space(); + let total_space = c.total_space(); + let available_space = c.available_space(); let used_space = total_space - available_space; format!( r#""{}": {{"name": {:?}, "total": {}, "free": {}, "used": {}, "used_perc": {}}}"#, - c.get_mount_point().display(), - c.get_name(), + c.mount_point().display(), + c.name(), total_space, available_space, used_space, @@ -37,15 +37,15 @@ pub fn get_ram() -> String { let mut c = SYSTEM.lock().unwrap(); c.refresh_memory(); - let total_memory = c.get_total_memory(); - let available_memory = c.get_available_memory(); + let total_memory = c.total_memory(); + let available_memory = c.available_memory(); let used_memory = total_memory as f32 - available_memory as f32; format!( r#"{{"total_mem": {}, "free_mem": {}, "total_swap": {}, "free_swap": {}, "available_mem": {}, "used_mem": {}, "used_mem_perc": {}}}"#, total_memory, - c.get_free_memory(), - c.get_total_swap(), - c.get_free_swap(), + c.free_memory(), + c.total_swap(), + c.free_swap(), available_memory, used_memory, (used_memory / total_memory as f32) * 100f32, @@ -58,9 +58,9 @@ pub fn get_temperatures() -> String { c.refresh_components(); format!( "{{ {} }}", - c.get_components() + c.components() .iter() - .map(|c| format!(r#""{}": {}"#, c.get_label().to_uppercase().replace(" ", "_"), c.get_temperature())) + .map(|c| format!(r#""{}": {}"#, c.label().to_uppercase().replace(" ", "_"), c.temperature())) .join(",") ) } @@ -68,19 +68,14 @@ pub fn get_temperatures() -> String { pub fn get_cpus() -> String { let mut c = SYSTEM.lock().unwrap(); c.refresh_cpu(); - let processors = c.get_processors(); + let processors = c.processors(); format!( r#"{{ "cores": [{}], "avg": {} }}"#, processors .iter() - .map(|a| format!( - r#"{{"core": "{}", "freq": {}, "usage": {:.0}}}"#, - a.get_name(), - a.get_frequency(), - a.get_cpu_usage() - )) + .map(|a| format!(r#"{{"core": "{}", "freq": {}, "usage": {:.0}}}"#, a.name(), a.frequency(), a.cpu_usage())) .join(","), - processors.iter().map(|a| a.get_cpu_usage()).avg() + processors.iter().map(|a| a.cpu_usage()).avg() ) } @@ -159,8 +154,8 @@ pub fn get_battery_capacity() -> Result { #[cfg(not(target_os = "macos"))] #[cfg(not(target_os = "linux"))] -pub fn get_battery_capacity() -> Result { - anyhow!("Eww doesn't support your OS for getting the battery capacity") +pub fn get_battery_capacity() -> Result { + Err(anyhow::anyhow!("Eww doesn't support your OS for getting the battery capacity")) } pub fn net() -> String { @@ -168,9 +163,9 @@ pub fn net() -> String { c.refresh_networks_list(); let interfaces = format!( "{{ {} }}", - &c.get_networks() + &c.networks() .iter() - .map(|a| format!(r#""{}": {{ "NET_UP": {}, "NET_DOWN": {} }}"#, a.0, a.1.get_transmitted(), a.1.get_received())) + .map(|a| format!(r#""{}": {{ "NET_UP": {}, "NET_DOWN": {} }}"#, a.0, a.1.transmitted(), a.1.received())) .join(","), ); interfaces