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:
2026-10-30 13:16:10 +01:00
parent e5bfc19aa6
commit 4782bbadd0
4 changed files with 20 additions and 7 deletions
+3 -1
View File
@@ -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"),
}
+9
View File
@@ -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()));