Skip to content

Commit cfaa866

Browse files
committed
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.
1 parent 8d9da92 commit cfaa866

File tree

1 file changed

+6
-2
lines changed
  • plugins/src/desktop_entries

1 file changed

+6
-2
lines changed

plugins/src/desktop_entries/mod.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ pub(crate) mod utils;
1515

1616
pub async fn main() {
1717
let mut app = App::new(async_stdout());
18-
app.reload().await;
1918

2019
let mut requests = json_input_stream(async_stdin());
2120

@@ -25,7 +24,12 @@ pub async fn main() {
2524
Request::Activate(id) => app.activate(id).await,
2625
Request::ActivateContext { id, context } => app.activate_context(id, context).await,
2726
Request::Context(id) => app.context(id).await,
28-
Request::Search(query) => app.search(&query).await,
27+
Request::Search(query) => {
28+
if query.is_empty() {
29+
app.reload().await;
30+
}
31+
app.search(&query).await;
32+
}
2933
Request::Exit => break,
3034
_ => (),
3135
},

0 commit comments

Comments
 (0)