diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index e76c2c6..89aadb5 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -658,6 +658,30 @@ fn read_start_minimized(app: &tauri::AppHandle) -> bool { .unwrap_or(true) } +/// cinny-desktop #37: whether a tray host exists to show our tray icon. On +/// stock GNOME there is no StatusNotifier host, so "keep running in the tray" +/// hides the window with no icon to bring it back. Always true off Linux. +#[tauri::command] +fn has_tray_host() -> bool { + #[cfg(target_os = "linux")] + { + let Ok(conn) = zbus::blocking::Connection::session() else { + return false; + }; + let Ok(proxy) = zbus::blocking::fdo::DBusProxy::new(&conn) else { + return false; + }; + let Ok(name) = zbus::names::BusName::try_from("org.kde.StatusNotifierWatcher") else { + return false; + }; + proxy.name_has_owner(name).unwrap_or(false) + } + #[cfg(not(target_os = "linux"))] + { + true + } +} + #[tauri::command] fn get_start_minimized(app: tauri::AppHandle) -> bool { read_start_minimized(&app) @@ -977,6 +1001,7 @@ pub fn run() { builder = builder .invoke_handler(tauri::generate_handler![ set_badge_count, + has_tray_host, set_tray_unread, get_tray_dnd, set_tray_update_ready,