mirror of
https://github.com/narrrl/proton-drive-linux.git
synced 2026-11-04 00:47:00 +01:00
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.
21 lines
656 B
Rust
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()
|
|
}
|