Tray icon never appears when the StatusNotifierHost registers after UI startup (tray availability is only checked once)

Aperta
#1,659 1 commento 2 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
72/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
python
Ambito
desktop

Direzione di ricerca

Inizia in service.py, in _setup_tray(), intorno alla riga 219, e analizza _show_gui_if_tray_not_available() intorno alla riga 258. Riproduci la race condition di avvio di Wayland con un host StatusNotifier che si registra in ritardo, quindi segui la configurazione esistente di QSystemTrayIcon e l’approccio suggerito con QDBusServiceWatcher. Il lavoro è completato quando l’icona nell’area di notifica appare dopo la registrazione dell’host senza riavviare opensnitch-ui, mentre il fallback di 10 secondi continua a comportarsi come previsto.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Describe the bug

opensnitch-ui creates its QSystemTrayIcon exactly once during startup
(_setup_tray(), service.py L219 in v1.7.2). Qt decides at icon creation
time which backend to use: if the StatusNotifier host is not registered
yet (IsStatusNotifierHostRegistered on org.kde.StatusNotifierWatcher),
Qt silently falls back to XEmbed — which does not exist on Wayland — and
never switches back. Result: no tray icon for the whole session, even though
a fully working tray appears a moment later.

The existing 10 s fallback (_show_gui_if_tray_not_available(), L258) only
opens the stats window; it does not retry the tray registration.

This is easy to hit with bars/shells that claim the
org.kde.StatusNotifierWatcher name early in their startup but register
the host only after their UI has finished loading (e.g. Quickshell /
DankMaterialShell). XDG autostart then races the bar on every login: the
watcher name is already on the bus, but the host isn't there yet when
opensnitch-ui performs its one-shot check.

To Reproduce
  1. Wayland session (Hyprland) with a Quickshell-based bar (DankMaterialShell), opensnitch-ui in XDG autostart.
  2. Log in. opensnitch-ui starts ~1 s before the bar's tray host is registered.
  3. busctl --user get-property org.kde.StatusNotifierWatcher /StatusNotifierWatcher org.kde.StatusNotifierWatcher RegisteredStatusNotifierItems → as 0 although opensnitch-ui is running; no icon for the whole session.
  4. systemctl --user restart of the UI (after the bar is up) → icon appears immediately.
Expected behavior

The UI should (re-)register its tray icon when a StatusNotifier host becomes
available after startup — e.g. via a QDBusServiceWatcher on
org.kde.StatusNotifierWatcher plus re-checking IsStatusNotifierHostRegistered,
recreating the QSystemTrayIcon when the host appears. GTK apps and most
Electron apps handle this; any once-only check loses the race by design.

Workaround

systemd user drop-in for the autostart unit that delays the UI until the
host is registered:

[Service]
ExecStartPre=/bin/sh -c 'for i in $(seq 100); do busctl --user get-property org.kde.StatusNotifierWatcher /StatusNotifierWatcher org.kde.StatusNotifierWatcher IsStatusNotifierHostRegistered 2>/dev/null | grep -q true && exit 0; sleep 0.1; done'

Note: waiting for the watcher name alone is not sufficient (see above) —
the host property is the condition Qt actually checks.

Environment
  • OpenSnitch 1.7.2 (daemon + UI), Arch Linux / CachyOS
  • Qt 5.15.18, PyQt 5.15.11, running via XWayland (xcb platform; Wayland plugin not found)
  • Hyprland + DankMaterialShell 1.5.3 (Quickshell 0.3.1) as StatusNotifier watcher/host

Related: #940 (--background helps starting without a tray, but does not
make the icon appear once a tray shows up later).

Lingua principale
Python
Stelle
14.3k
Fork
689
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di evilsocket/opensnitch

Tutte le issue di evilsocket/opensnitch

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.