Aw-qt: Wait for tray to avoid crashes when starting before tray finished loading

I’m on the sway window manager which doesn’t support XDG autostart. Instead, I launch aw-qt from the sway config file. For the system tray I use waybar. In the sway config I enable both via the lines

bar swaybar_command waybar
exec "sleep 2 && aw-qt --autostart-modules aw-server,aw-watcher-window-wayland"

I needed the sleep because otherwise aw-qt crashed with an error message that no tray was found, with the sleep it fine. From the sway config I launch other applications with tray icons like fcitx5 and udiskie and there the tray works without issues and without requiring a sleep. I don’t know how they achieve that.

One possible solution would be to add a wait for the tray to become available, e.g. do retries for 30s and then only give the error message after the timeout finished. This is not really a “bug”, as it’s not an error to crash when there is not a tray, but would be an improvement to the UX in some cases like mine.