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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017PCb59uY3UKqDqt7B6hzd5
This commit is contained in:
Lotus CI
2026-10-18 02:41:03 -04:00
co-authored by Claude Opus 5.5
parent f5fc18e571
commit e78b5b911d
+25
View File
@@ -658,6 +658,30 @@ fn read_start_minimized(app: &tauri::AppHandle) -> bool {
.unwrap_or(true) .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] #[tauri::command]
fn get_start_minimized(app: tauri::AppHandle) -> bool { fn get_start_minimized(app: tauri::AppHandle) -> bool {
read_start_minimized(&app) read_start_minimized(&app)
@@ -977,6 +1001,7 @@ pub fn run() {
builder = builder builder = builder
.invoke_handler(tauri::generate_handler![ .invoke_handler(tauri::generate_handler![
set_badge_count, set_badge_count,
has_tray_host,
set_tray_unread, set_tray_unread,
get_tray_dnd, get_tray_dnd,
set_tray_update_ready, set_tray_update_ready,