From a9bb3ed8c9bda28f3a4839d7893dbfac8088b5ec Mon Sep 17 00:00:00 2001 From: luxluth Date: Wed, 18 Dec 2024 11:14:40 +0100 Subject: [PATCH] taking into account the no-display label in desktop files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some time, there are some `.desktop` file that doesn't want to be displayed. Like this : ```ìni NoDisplay=true ``` Removing them, eliminates a lot of noises in the app search --- src/app.rs | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/app.rs b/src/app.rs index fdc965d..d4a57ea 100644 --- a/src/app.rs +++ b/src/app.rs @@ -47,17 +47,21 @@ pub fn collect_apps() -> Vec { .into_iter() .filter_map(|p| { if let Ok(entry) = DesktopEntry::from_path(p.clone(), Some(&locales)) { - return Some(AppEntry { - exec: entry.exec().unwrap_or_default().to_string(), - need_terminal: entry.terminal(), - icon: entry - .icon() - .unwrap_or("application-x-executable") - .to_string(), - name: entry.name(&locales).unwrap_or_default().to_string(), - description: entry.comment(&locales).unwrap_or_default().to_string(), - _path: p, - }); + if entry.no_display() { + return None; + } else { + return Some(AppEntry { + exec: entry.exec().unwrap_or_default().to_string(), + need_terminal: entry.terminal(), + icon: entry + .icon() + .unwrap_or("application-x-executable") + .to_string(), + name: entry.name(&locales).unwrap_or_default().to_string(), + description: entry.comment(&locales).unwrap_or_default().to_string(), + _path: p, + }); + } } None