From cfaa866873722bacad70b36b965d5c3d8612d883 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Janis=20K=C3=B6nig?= Date: Mon, 21 Apr 2025 00:22:35 +0200 Subject: [PATCH] desktop_entries: Reload .desktop on search Since pop-launcher has been demonized, the desktop_entries plugin isn't relaunched on every search anymore. In consequence, it is not providing up-to-date results when .desktop files have changed (e.g., on un-/installation of a new application) anymore. Move the app.reload() call into the request loop to trigger a re-index. In a release-build this has been fine performance wise on an 8th Gen i5 laptop device. As a small performance improvement, only trigger this update on a search event and if the search query is empty. Alternatives could include remembering the last time the index was built (initialised to UNIX_EPOCH before the loop) and only conditionally triggering a re-index after a hot-period of 10s since the last run. In our testing this didn't result in any noticeable difference. --- plugins/src/desktop_entries/mod.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/src/desktop_entries/mod.rs b/plugins/src/desktop_entries/mod.rs index 92d6a02..9b701a7 100644 --- a/plugins/src/desktop_entries/mod.rs +++ b/plugins/src/desktop_entries/mod.rs @@ -15,7 +15,6 @@ pub(crate) mod utils; pub async fn main() { let mut app = App::new(async_stdout()); - app.reload().await; let mut requests = json_input_stream(async_stdin()); @@ -25,7 +24,12 @@ pub async fn main() { Request::Activate(id) => app.activate(id).await, Request::ActivateContext { id, context } => app.activate_context(id, context).await, Request::Context(id) => app.context(id).await, - Request::Search(query) => app.search(&query).await, + Request::Search(query) => { + if query.is_empty() { + app.reload().await; + } + app.search(&query).await; + } Request::Exit => break, _ => (), },