ActivityWatch / aw-qt

Tray icon that manages ActivityWatch processes, built with Qt.
Mozilla Public License 2.0
27 stars 32 forks source link

Application exits prematurely if QSystemTrayIcon.isSystemTrayAvailable() is false #97

Open huantianad opened 1 year ago

huantianad commented 1 year ago

On startup, aw-qt checks if QSystemTrayIcon.isSystemTrayAvailable() is false. If there isn't a system tray available, it simply exits since it cannot show an icon. This behavior makes sense most of the time.

However, on my system running KDE Plasma 5.27.3 (and I'd assume other Plasma systems), autostart programs are called before the panel containing a system tray is loaded. This causes aw-qt to crash on startup, as it tries to find a system tray, but Plasma has not yet loaded it.

This can simply be fixed by skipping or delaying the check to QSystemTrayIcon.isSystemTrayAvailable(). According to the QT docs, "If the system tray is currently unavailable but becomes available later, QSystemTrayIcon will automatically add an entry in the system tray if it is visible." Therefore, even if on startup QSystemTrayIcon.isSystemTrayAvailable() is false, QSystemTrayIcon will still properly display once the system tray is loaded.