diff --git a/Cargo.lock b/Cargo.lock index da36025f..125bf6e1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -544,7 +544,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "778e2ac28f6c47af28e4907f13ffd1e1ddbd400980a9abd7c8df189bf578a5ad" dependencies = [ "libc", - "windows-sys 0.59.0", + "windows-sys 0.60.2", ] [[package]] @@ -586,12 +586,12 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" [[package]] name = "freedesktop_entry_parser" -version = "1.3.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db9c27b72f19a99a895f8ca89e2d26e4ef31013376e56fdafef697627306c3e4" +checksum = "2b368437186ec63ceb50d0832ee1ebcb5878037fe16ead1c68081d4aee0d140a" dependencies = [ + "indexmap", "nom", - "thiserror 1.0.69", ] [[package]] @@ -826,9 +826,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.10.0" +version = "2.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe4cd85333e22411419a0bcae1297d25e58c9443848b11dc6a86fefe8c78a661" +checksum = "4b0f83760fb341a774ed326568e19f5a863af4a952def8c39f9ab92fd95b88e5" dependencies = [ "equivalent", "hashbrown", @@ -907,12 +907,6 @@ version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" -[[package]] -name = "minimal-lexical" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" - [[package]] name = "miniz_oxide" version = "0.8.3" @@ -941,12 +935,11 @@ dependencies = [ [[package]] name = "nom" -version = "7.1.3" +version = "8.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +checksum = "df9761775871bdef83bee530e60050f7e54b1105350d6884eb0fb4f46c2f9405" dependencies = [ "memchr", - "minimal-lexical", ] [[package]] @@ -1047,7 +1040,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7d8fae84b431384b68627d0f9b3b1245fcf9f46f6c0e3dc902e9dce64edd1967" dependencies = [ "libc", - "windows-sys 0.59.0", + "windows-sys 0.60.2", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 3da4b066..57276087 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -93,7 +93,7 @@ plist = "1" ureq = { version = "3", default-features = false, features = ["gzip"] } [target."cfg(target_os = \"linux\")".dependencies] -freedesktop_entry_parser = "1.3" +freedesktop_entry_parser = "2.0" [target."cfg(unix)".dependencies] libc = "0.2" diff --git a/src/opts.rs b/src/opts.rs index 12f09ef5..2ddd2d80 100644 --- a/src/opts.rs +++ b/src/opts.rs @@ -2,19 +2,14 @@ use serde::{Deserialize, Serialize}; #[cfg(feature = "cli")] use structopt::clap::arg_enum; -#[derive(Clone, Copy, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize)] +#[derive(Clone, Copy, Debug, Default, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize)] pub enum NoiseLevel { + #[default] Polite, LoudAndProud, FranklyQuitePedantic, } -impl Default for NoiseLevel { - fn default() -> Self { - Self::Polite - } -} - impl NoiseLevel { pub fn from_occurrences(occurrences: u64) -> Self { match occurrences { diff --git a/src/os/linux/mod.rs b/src/os/linux/mod.rs index c85878c7..a13404f7 100644 --- a/src/os/linux/mod.rs +++ b/src/os/linux/mod.rs @@ -74,13 +74,13 @@ impl Application { // We absolutely want the Exec value exec_command: parsed_entry .section("Desktop Entry") - .attr("Exec") + .and_then(|s| s.attr("Exec").first()) .ok_or(DetectEditorError::ExecFieldMissing)? .into(), // The icon is optional, we try getting it because the Exec value may need it icon: parsed_entry .section("Desktop Entry") - .attr("Icon") + .and_then(|s| s.attr("Icon").first()) .map(Into::into), xdg_entry_path: entry_filepath, }) @@ -136,15 +136,14 @@ pub fn open_file_with( let command_parts = entry .section("Desktop Entry") - .attr("Exec") + .and_then(|s| s.attr("Exec").first()) .map(|str_entry| { - let osstring_entry: OsString = str_entry.into(); xdg::parse_command( - &osstring_entry, + str_entry.as_ref(), path_str, entry .section("Desktop Entry") - .attr("Icon") + .and_then(|s| s.attr("Icon").first()) .map(|s| s.as_ref()), Some(&entry_path), ) diff --git a/src/os/linux/xdg.rs b/src/os/linux/xdg.rs index 2ae3ec5f..cc4b5ab6 100644 --- a/src/os/linux/xdg.rs +++ b/src/os/linux/xdg.rs @@ -67,8 +67,8 @@ pub fn find_entry_by_app_name( if let Ok(parsed) = parse_entry(&entry_path) { if parsed .section("Desktop Entry") - .attr("Name") - .map(str::as_ref) + .and_then(|s| s.attr("Name").first()) + .map(|s| s.as_ref()) == Some(app_name) { return Some((parsed, entry_path));