Files
proton-drive-linux/crates/pdfs-core/src/tray.rs
T
nvrl f6136ce344 feat(core,gui): tray states and menu
The tray icon follows the drive's phase (synced, syncing, paused,
offline, needs attention) and reports NeedsAttention while changes keep
failing. The menu gains an issues item that opens the Sync page, Sign In
when signed out, Hide Tray Icon (persisted as tray_hidden) and Stop
Proton Drive, which pdfs-app confirms via --confirm-stop. A second
pdfs-app launch raises the running window.
2026-09-23 03:55:51 +02:00

21 lines
656 B
Rust

//! Talking to a running `pdfs-tray`.
//!
//! The tray binds [`AppDirs::tray_socket`] to keep a single instance. The same
//! socket takes one command, [`QUIT`], so the desktop app can take the icon
//! away when the user hides it or stops Proton Drive.
use std::io::Write;
use std::os::unix::net::UnixStream;
use crate::config::AppDirs;
/// The line that asks the tray to exit.
pub const QUIT: &str = "quit";
/// Ask a running tray to exit. False when no tray answers.
pub fn quit(dirs: &AppDirs) -> bool {
UnixStream::connect(dirs.tray_socket())
.and_then(|mut stream| stream.write_all(format!("{QUIT}\n").as_bytes()))
.is_ok()
}