Skip to content

Native iCloud apps for Windows and Linux, built in Rust. Notes, Reminders, Calendar, Contacts, Drive and Photos, offline and in sync with your iPhone.

Linux tray: its handle kept for the app's life

Yashwanth Kamireddi4b77ea9d22ee
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs
index e49a803..04a77c7 100644
--- a/src-tauri/src/main.rs
+++ b/src-tauri/src/main.rs
@@ -6106,6 +6106,9 @@ mod linux_tray {
.collect()
}
+ /// The tray's handle, held so ksni's service keeps a reason to wait (see `spawn`).
+ static HANDLE: std::sync::OnceLock<ksni::Handle<SkykeepTray>> = std::sync::OnceLock::new();
+
pub fn spawn(app: tauri::AppHandle) {
let tray = SkykeepTray {
app,
@@ -6121,8 +6124,14 @@ mod linux_tray {
.spawn()
.await
{
- // The service runs on its own; the handle is only for changing it later.
- Ok(_handle) => MADE.store(true, Ordering::SeqCst),
+ // Kept for as long as the app runs. Dropped, it closed ksni's command channel,
+ // and when the session bus then went too (logging out, a session ending) both
+ // of ksni's waits were over and its loop panicked ("all futures in select!
+ // were completed").
+ Ok(handle) => {
+ let _ = HANDLE.set(handle);
+ MADE.store(true, Ordering::SeqCst);
+ }
Err(e) => quiet!("no tray on this desktop, so closing the window quits: {e}"),
}
});