diff --git a/Cargo.lock b/Cargo.lock index 983f419..97cf7b0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1109,9 +1109,9 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" [[package]] name = "freedesktop-desktop-entry" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "287f89b1a3d88dd04d2b65dfec39f3c381efbcded7b736456039c4ee49d54b17" +checksum = "c201444ddafb5506fe85265b48421664ff4617e3b7090ef99e42a0070c1aead0" dependencies = [ "dirs 3.0.2", "gettext-rs", diff --git a/client/src/plugin/applications.rs b/client/src/plugin/applications.rs index d8094e7..1e7d812 100644 --- a/client/src/plugin/applications.rs +++ b/client/src/plugin/applications.rs @@ -5,33 +5,19 @@ pub struct ApplicationsPlugin { entries: Vec, } -fn read_desktop_entry(path: &std::path::PathBuf) -> anyhow::Result { - let pathstr = path.to_str().unwrap_or(""); - let bytes = std::fs::read_to_string(path)?; - let desktop_entry = freedesktop_desktop_entry::DesktopEntry::decode(path, &bytes)?; +fn to_entry( + desktop_entry: &freedesktop_desktop_entry::DesktopEntry, + terminal_command: Option, +) -> Option { + let title = name(desktop_entry); if !is_visible(&desktop_entry) { - return Err(anyhow::anyhow!( - "Desktop entry at path '{}' is hidden.", - pathstr - )); + log::debug!(target: "applications", "Desktop entry with name '{}' will be hidden because of its properties.", title); + return None; } - let locale = std::env::var("LANG").unwrap_or(String::from("en_US")); - let title = desktop_entry - .name(Some(&locale)) - .context(format!( - "Desktop entry at path '{}' is missing the 'name' field.", - pathstr - ))? - .to_string(); - - let cmd = desktop_entry - .exec() - .context(format!( - "Desktop entry at path '{}' is missing the 'exec' field.", - pathstr - ))? + let mut cmd: Vec = desktop_entry + .exec()? .split_ascii_whitespace() .filter_map(|s| { if s.starts_with('%') { @@ -42,13 +28,23 @@ fn read_desktop_entry(path: &std::path::PathBuf) -> anyhow::Result