From e78b5b911d5dc6e3ceed5ba8f2c6b4dbee676674 Mon Sep 17 00:00:00 2001 From: Lotus CI Date: Sun, 18 Oct 2026 02:41:03 -0400 Subject: [PATCH] feat(tray): has_tray_host command so the first-close dialog can tell when there is no tray (#37) On stock GNOME there is no StatusNotifier host, so choosing "Keep running in the tray" hid the window with no icon to bring it back. Expose whether org.kde.StatusNotifierWatcher has an owner on the session bus (always true off Linux); cinny's dialog then defaults to Quit and words the other option as "running in the background". Refs #37 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_017PCb59uY3UKqDqt7B6hzd5 --- src-tauri/src/lib.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) 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,