diff --git a/Cargo.lock b/Cargo.lock index bc4ae0fe..ec1dd91a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -729,12 +729,6 @@ dependencies = [ "system-deps", ] -[[package]] -name = "gtk-macros" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da5bf7748fd4cd0b2490df8debcc911809dbcbee4ece9531b96c29a9c729de5a" - [[package]] name = "gtk4" version = "0.9.3" @@ -958,9 +952,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.161" +version = "0.2.162" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1" +checksum = "18d287de67fe55fd7e1581fe933d965a5a9477b38e949cfa9f8574ef01506398" [[package]] name = "libloading" @@ -1340,7 +1334,6 @@ dependencies = [ "clap", "gettext-rs", "glob", - "gtk-macros", "gtk4", "lazy-regex", "libadwaita", diff --git a/Cargo.toml b/Cargo.toml index f7f5a7d2..ec422b28 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,9 +24,8 @@ clap = { version = "4.5.20", features = ["derive"] } gettext-rs = { version = "0.7.2", features = ["gettext-system"] } glob = "0.3.1" gtk = { version = "0.9.3", features = ["v4_10"], package = "gtk4" } -gtk-macros = "0.3.0" lazy-regex = "3.3.0" -libc = { version = "0.2.161", features = ["extra_traits"] } +libc = { version = "0.2.162", features = ["extra_traits"] } log = "0.4.22" nix = { version = "0.29.0", default-features = false, features = [ "signal", diff --git a/lib/process_data/Cargo.lock b/lib/process_data/Cargo.lock index 1c5b4237..2136e5f6 100644 --- a/lib/process_data/Cargo.lock +++ b/lib/process_data/Cargo.lock @@ -4,18 +4,18 @@ version = 3 [[package]] name = "aho-corasick" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" dependencies = [ "memchr", ] [[package]] name = "anyhow" -version = "1.0.89" +version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6" +checksum = "4c95c10ba0b00a02636238b814946408b1322d5ac4760326e6fb8ec956d85775" [[package]] name = "bitflags" @@ -25,11 +25,11 @@ checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "cc" -version = "1.0.83" +version = "1.1.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +checksum = "40545c26d092346d8a8dab71ee48e7685a7a9cba76e634790c215b41a4a7b4cf" dependencies = [ - "libc", + "shlex", ] [[package]] @@ -189,9 +189,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.159" +version = "0.2.162" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" +checksum = "18d287de67fe55fd7e1581fe933d965a5a9477b38e949cfa9f8574ef01506398" [[package]] name = "libloading" @@ -205,15 +205,15 @@ dependencies = [ [[package]] name = "log" -version = "0.4.21" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] name = "memchr" -version = "2.6.4" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "num_cpus" @@ -289,9 +289,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.86" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" dependencies = [ "unicode-ident", ] @@ -307,7 +307,6 @@ dependencies = [ "num_cpus", "nutype", "nvml-wrapper", - "once_cell", "pretty_assertions", "serde", "syscalls", @@ -318,18 +317,18 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.36" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2", ] [[package]] name = "regex" -version = "1.11.0" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" dependencies = [ "aho-corasick", "memchr", @@ -356,18 +355,18 @@ checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "serde" -version = "1.0.210" +version = "1.0.214" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" +checksum = "f55c3193aca71c12ad7890f1785d2b73e1b9f63a0bbc353c08ef26fe03fc56b5" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.210" +version = "1.0.214" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" +checksum = "de523f781f095e28fa605cdce0f8307e451cc0fd14e2eb4cd2e98a355b147766" dependencies = [ "proc-macro2", "quote", @@ -376,15 +375,21 @@ dependencies = [ [[package]] name = "serde_repr" -version = "0.1.17" +version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3081f5ffbb02284dda55132aa26daecedd7372a42417bbbab6f14ab7d6bb9145" +checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", "syn", ] +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + [[package]] name = "static_assertions" version = "1.1.0" @@ -399,9 +404,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "syn" -version = "2.0.72" +version = "2.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af" +checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" dependencies = [ "proc-macro2", "quote", @@ -432,18 +437,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.50" +version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2" +checksum = "02dd99dc800bbb97186339685293e1cc5d9df1f8fae2d0aecd9ff1c77efea892" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.50" +version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" +checksum = "a7c61ec9a6f64d2793d8a45faba21efbe3ced62a886d44c36a009b2b519b4c7e" dependencies = [ "proc-macro2", "quote", @@ -458,15 +463,15 @@ checksum = "ccb97dac3243214f8d8507998906ca3e2e0b900bf9bf4870477f125b82e68f6e" [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] name = "unicode-segmentation" -version = "1.11.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" +checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" [[package]] name = "urlencoding" diff --git a/lib/process_data/Cargo.toml b/lib/process_data/Cargo.toml index 64a8c3b2..34aba82b 100644 --- a/lib/process_data/Cargo.toml +++ b/lib/process_data/Cargo.toml @@ -20,7 +20,7 @@ opt-level = 3 anyhow = "1.0.93" glob = "0.3.1" lazy-regex = "3.3.0" -libc = "0.2.161" +libc = "0.2.162" num_cpus = "1.16.0" nutype = { version = "0.5.0", features = ["serde"] } nvml-wrapper = "0.10.0" diff --git a/lib/process_data/src/lib.rs b/lib/process_data/src/lib.rs index b2f83d2a..4bc932fa 100644 --- a/lib/process_data/src/lib.rs +++ b/lib/process_data/src/lib.rs @@ -17,7 +17,7 @@ use std::os::linux::fs::MetadataExt; use std::path::Path; use std::str::FromStr; use std::sync::{LazyLock, RwLock}; -use std::{path::PathBuf, time::SystemTime}; +use std::time::SystemTime; const STAT_OFFSET: usize = 2; // we split the stat contents where the executable name ends, which is the second element const STAT_PARENT_PID: usize = 3 - STAT_OFFSET; @@ -236,7 +236,8 @@ impl ProcessData { Ok(process_data) } - pub fn try_from_path(proc_path: &PathBuf) -> Result { + pub fn try_from_path>(proc_path: P) -> Result { + let proc_path = proc_path.as_ref(); let stat = std::fs::read_to_string(proc_path.join("stat"))?; let statm = std::fs::read_to_string(proc_path.join("statm"))?; let status = std::fs::read_to_string(proc_path.join("status"))?; @@ -338,7 +339,7 @@ impl ProcessData { let cgroup = std::fs::read_to_string(proc_path.join("cgroup")) .ok() - .and_then(|raw| Self::sanitize_cgroup(raw)); + .and_then(Self::sanitize_cgroup); let containerization = if commandline.starts_with("/snap/") { Containerization::Snap diff --git a/src/lib.rs b/src/lib.rs index 4ec1c367..b208f64f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,5 @@ pub mod application; +#[rustfmt::skip] pub mod config; pub mod gui; pub mod i18n; diff --git a/src/ui/pages/gpu.rs b/src/ui/pages/gpu.rs index d0dd0e29..21f5f219 100644 --- a/src/ui/pages/gpu.rs +++ b/src/ui/pages/gpu.rs @@ -387,7 +387,7 @@ impl ResGPU { imp.temperature.graph().set_visible(temperature.is_some()); if let Some(temperature) = temperature { - let temperature_string = convert_temperature(*temperature as f64); + let temperature_string = convert_temperature(*temperature); let highest_temperature_string = convert_temperature(imp.temperature.graph().get_highest_value()); @@ -398,7 +398,7 @@ impl ResGPU { i18n("Highest:"), highest_temperature_string )); - imp.temperature.graph().push_data_point(*temperature as f64); + imp.temperature.graph().push_data_point(*temperature); usage_percentage_string.push_str(" · "); usage_percentage_string.push_str(&temperature_string); diff --git a/src/ui/pages/npu.rs b/src/ui/pages/npu.rs index 35e24ea7..5a8be1d6 100644 --- a/src/ui/pages/npu.rs +++ b/src/ui/pages/npu.rs @@ -310,7 +310,7 @@ impl ResNPU { } if let Some(temperature) = temperature { - let temperature_string = convert_temperature(*temperature as f64); + let temperature_string = convert_temperature(*temperature); let highest_temperature_string = convert_temperature(imp.temperature.graph().get_highest_value()); @@ -321,7 +321,7 @@ impl ResNPU { i18n("Highest:"), highest_temperature_string )); - imp.temperature.graph().push_data_point(*temperature as f64); + imp.temperature.graph().push_data_point(*temperature); usage_percentage_string.push_str(" · "); usage_percentage_string.push_str(&temperature_string); diff --git a/src/utils/app.rs b/src/utils/app.rs index 17c52e63..1cda7011 100644 --- a/src/utils/app.rs +++ b/src/utils/app.rs @@ -252,7 +252,7 @@ impl App { .context("unable to get ID of desktop file")?; if let Some(reason) = APP_ID_BLOCKLIST.get(id.as_str()) { - debug!("Skipping {id} because it's blocklisted (reason: {reason})"); + debug!("Skipping {id} because it's blocklisted ({reason})"); bail!("{id} is blocklisted (reason: {reason})") } @@ -330,7 +330,7 @@ impl App { let containerization = if is_flatpak { debug!( - "Found Flatpak app \"{display_name}\" (ID: {id}) at {} with commandline `{}` (detected executable name: {})", + "Found Flatpak app \"{display_name}\" (ID: {id:?}) at {} with commandline `{}` (detected executable name: {})", file_path.to_string_lossy(), commandline.as_ref().unwrap_or(&"".into()), executable_name.as_ref().unwrap_or(&"".into()), @@ -338,7 +338,7 @@ impl App { Containerization::Flatpak } else if is_snap { debug!( - "Found Snap app \"{display_name}\" (ID: {id}) at {} with commandline `{}` (detected executable name: {})", + "Found Snap app \"{display_name}\" (ID: {id:?}) at {} with commandline `{}` (detected executable name: {})", file_path.to_string_lossy(), commandline.as_ref().unwrap_or(&"".into()), executable_name.as_ref().unwrap_or(&"".into()), @@ -346,7 +346,7 @@ impl App { Containerization::Snap } else { debug!( - "Found native app \"{display_name}\" (ID: {id}) at {} with commandline `{}` (detected executable name: {})", + "Found native app \"{display_name}\" (ID: {id:?}) at {} with commandline `{}` (detected executable name: {})", file_path.to_string_lossy(), commandline.as_ref().unwrap_or(&"".into()), executable_name.as_ref().unwrap_or(&"".into()), @@ -654,22 +654,22 @@ impl AppsContext { .get(&Some(process.data.cgroup.clone().unwrap_or_default())) { debug!( - "Associating process {} with app \"{}\" (ID: {:?}) based on process cgroup matching with app ID", - process.data.pid, app.display_name, app.id + "Associating process {} with app {:?} (ID: {:?}) based on process cgroup matching with app ID", + process.data.pid, app.display_name, app.id.as_deref().unwrap_or("N/A") ); app.id.clone() } else if let Some(app) = self.apps.get(&Some(process.executable_path.clone())) { // ↑ look for whether we can find an ID in the executable path of the process debug!( - "Associating process {} with app \"{}\" (ID: {:?}) based on process executable path matching with app ID", - process.data.pid, app.display_name, app.id + "Associating process {} with app {:?} (ID: {:?}) based on process executable path matching with app ID", + process.data.pid, app.display_name, app.id.as_deref().unwrap_or("N/A") ); app.id.clone() } else if let Some(app) = self.apps.get(&Some(process.executable_name.clone())) { // ↑ look for whether we can find an ID in the executable name of the process debug!( - "Associating process {} with app \"{}\" (ID: {:?}) based on process executable name matching with app ID", - process.data.pid, app.display_name, app.id + "Associating process {} with app {:?} (ID: {:?}) based on process executable name matching with app ID", + process.data.pid, app.display_name, app.id.as_deref().unwrap_or("N/A") ); app.id.clone() } else { @@ -684,8 +684,8 @@ impl AppsContext { .is_some_and(|commandline| commandline == &process.executable_path) { debug!( - "Associating process {} with app \"{}\" (ID: {:?}) based on process executable pathmatching with app commandline ({})", - process.data.pid, app.display_name, app.id, process.executable_path + "Associating process {} with app {:?} (ID: {:?}) based on process executable path matching with app commandline ({})", + process.data.pid, app.display_name, app.id.as_deref().unwrap_or("N/A"), process.executable_path ); true } else if app @@ -694,8 +694,8 @@ impl AppsContext { .is_some_and(|executable_name| executable_name == &process.executable_name) { debug!( - "Associating process {} with app \"{}\" (ID: {:?}) based on process executable name matching with app executable name ({})", - process.data.pid, app.display_name, app.id, process.executable_name + "Associating process {} with app {:?} (ID: {:?}) based on process executable name matching with app executable name ({})", + process.data.pid, app.display_name, app.id.as_deref().unwrap_or("N/A"), process.executable_name ); true } else if app @@ -711,8 +711,8 @@ impl AppsContext { .unwrap_or(false) { debug!( - "Associating process {} with app \"{}\" (ID: {:?}) based on match in KNOWN_EXECUTABLE_NAME_EXCEPTIONS", - process.data.pid, app.display_name, app.id + "Associating process {} with app {:?} (ID: {:?}) based on match in KNOWN_EXECUTABLE_NAME_EXCEPTIONS", + process.data.pid, app.display_name, app.id.as_deref().unwrap_or("N/A") ); true } else { diff --git a/src/utils/battery.rs b/src/utils/battery.rs index 48479322..cee9602a 100644 --- a/src/utils/battery.rs +++ b/src/utils/battery.rs @@ -332,6 +332,7 @@ impl Battery { #[cfg(test)] mod test { use super::Battery; + use pretty_assertions::assert_eq; #[test] fn dont_untangle_untangled_string() { diff --git a/src/utils/cpu.rs b/src/utils/cpu.rs index 2941e4e3..876274c9 100644 --- a/src/utils/cpu.rs +++ b/src/utils/cpu.rs @@ -132,7 +132,7 @@ fn parse_lscpu>(lscpu_output: S) -> CpuInfo { let lscpu_output = lscpu_output.as_ref(); let model_name = RE_LSCPU_MODEL_NAME - .captures(&lscpu_output) + .captures(lscpu_output) .and_then(|captures| { captures .get(1) @@ -140,24 +140,24 @@ fn parse_lscpu>(lscpu_output: S) -> CpuInfo { }); let architecture = RE_LSCPU_ARCHITECTURE - .captures(&lscpu_output) + .captures(lscpu_output) .and_then(|captures| captures.get(1).map(|capture| capture.as_str().into())); let sockets = RE_LSCPU_SOCKETS - .captures(&lscpu_output) + .captures(lscpu_output) .and_then(|captures| { captures .get(1) .and_then(|capture| capture.as_str().parse().ok()) }); - let logical_cpus = RE_LSCPU_CPUS.captures(&lscpu_output).and_then(|captures| { + let logical_cpus = RE_LSCPU_CPUS.captures(lscpu_output).and_then(|captures| { captures .get(1) .and_then(|capture| capture.as_str().parse().ok()) }); - let physical_cpus = RE_LSCPU_CORES.captures(&lscpu_output).and_then(|captures| { + let physical_cpus = RE_LSCPU_CORES.captures(lscpu_output).and_then(|captures| { captures .get(1) .and_then(|capture| capture.as_str().parse::().ok()) @@ -165,11 +165,11 @@ fn parse_lscpu>(lscpu_output: S) -> CpuInfo { }); let virtualization = RE_LSCPU_VIRTUALIZATION - .captures(&lscpu_output) + .captures(lscpu_output) .and_then(|captures| captures.get(1).map(|capture| capture.as_str().into())); let max_speed = RE_LSCPU_MAX_MHZ - .captures(&lscpu_output) + .captures(lscpu_output) .and_then(|captures| { captures.get(1).and_then(|capture| { capture @@ -206,7 +206,7 @@ pub fn cpu_info() -> Result { .stdout, ) .context("unable to parse lscpu output to UTF-8") - .map(|output| parse_lscpu(output)) + .map(parse_lscpu) } /// Returns the frequency of the given CPU `core`