mirror of
https://github.com/deunix-educ/sourizz.git
synced 2026-11-25 04:39:43 +01:00
Tray: wait for the notification area instead of giving up, and record the Xfce field test
Started at login by the autostart, Sourizz could run before the session's panel published org.kde.StatusNotifierWatcher; ksni then failed once and the daemon stayed without an icon until restarted (seen on Xfce 4.20). The tray is now spawned with assume_sni_available(true), so it registers as soon as the watcher appears. Checked by stopping xfce4-panel, starting the daemon, and restarting the panel: the icon registered by itself. The READMEs list Xfce 4.20 as tested (12 automatic checks, global hotkeys, ring, trail, spotlight, keystrokes, clicks and sounds, annotation, settings window, tray icon and menu). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
+3
-1
@@ -66,7 +66,9 @@ impl Core {
|
||||
pub fn start_tray(&mut self) {
|
||||
use ksni::blocking::TrayMethods;
|
||||
let tray = TrayIcon { cfg: self.cfg.clone(), lang: Lang::resolve(&self.cfg.general.language), hub: self.hub.clone() };
|
||||
match tray.spawn() {
|
||||
// The session may start us before its panel publishes the notification area (autostart at
|
||||
// login): keep waiting for it rather than giving up, and the icon shows up once it exists.
|
||||
match tray.assume_sni_available(true).spawn() {
|
||||
Ok(h) => self.tray = Some(h),
|
||||
Err(e) => log::warn!("no system tray ({e}); control the daemon with the `sourizz` CLI or hotkeys"),
|
||||
}
|
||||
|
||||
@@ -96,6 +96,15 @@ impl ksni::Tray for TrayIcon {
|
||||
String::new()
|
||||
}
|
||||
|
||||
fn watcher_online(&self) {
|
||||
log::info!("system tray available");
|
||||
}
|
||||
|
||||
fn watcher_offline(&self, reason: ksni::OfflineReason) -> bool {
|
||||
log::info!("no system tray for now ({reason:?}); the icon appears when one starts");
|
||||
true
|
||||
}
|
||||
|
||||
/// Left click toggles everything.
|
||||
fn activate(&mut self, _x: i32, _y: i32) {
|
||||
self.hub.send(Command::Toggle("all".into()));
|
||||
|
||||
Reference in New Issue
Block a user