From 9303d23d47bd37cfffc67c909fe03942e1c877bf Mon Sep 17 00:00:00 2001 From: LordGrimmauld Date: Sun, 28 Apr 2024 11:17:49 +0200 Subject: [PATCH 1/2] update flake lock --- flake.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.lock b/flake.lock index e0130b9..4b521db 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1711655175, - "narHash": "sha256-1xiaYhC3ul4y+i3eicYxeERk8ZkrNjLkrFSb/UW36Zw=", + "lastModified": 1714245158, + "narHash": "sha256-9P2M0+tf1TE7Z5PwDVwhheuD2mFf6/phPr0Jvl7cxcc=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "64c81edb4b97a51c5bbc54c191763ac71a6517ee", + "rev": "2b1f64b358f2cab62617f26b3870fd0ee375d848", "type": "github" }, "original": { From b5ccb5f2ac217d49e3b0a792103e54d567252ad1 Mon Sep 17 00:00:00 2001 From: LordGrimmauld Date: Sun, 28 Apr 2024 12:12:15 +0200 Subject: [PATCH 2/2] Respect the specification some more --- plugin-desktop/src/main.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/plugin-desktop/src/main.rs b/plugin-desktop/src/main.rs index dba6ab8..420abb8 100644 --- a/plugin-desktop/src/main.rs +++ b/plugin-desktop/src/main.rs @@ -11,6 +11,7 @@ mod icons; static XDG_HOME_ENV: &'static str = "XDG_DATA_HOME"; static XDG_DATA_ENV: &'static str = "XDG_DATA_DIRS"; static XDG_CONFIG_ENV: &'static str = "XDG_CONFIG_HOME"; +static XDG_CURRENT_DESKTOP_ENV: &'static str = "XDG_CURRENT_DESKTOP"; static XDG_HOME_DEFAULT: &'static str = "~/.local/share"; static XDG_DATA_DEFAULT: &'static str = "/usr/share:/usr/local/share"; @@ -49,6 +50,19 @@ fn fix_exec(exec: &str) -> String { fn parse_desktop(path: &PathBuf, locale: Option<&str>) -> Option { let bytes = read_to_string(path).ok()?; let entry = DesktopEntry::decode(&path, &bytes).ok()?; + + // no-display entries should not be shown + if entry.no_display() { + return None; + } + + // if an entry only is shown on a specific desktop, check whether desktop is set and matches, + // otherwise return None + let de = std::env::var(XDG_CURRENT_DESKTOP_ENV); + if entry.only_show_in().is_some_and(|e| !(de.is_ok() && de.unwrap() == e.to_string())){ + return None; + } + let name = entry.name(locale)?.to_string(); let icon = entry.icon().map(|i| i.to_string()); let comment = entry.comment(locale).map(|s| s.to_string());