Show a working tray icon on Wayland (AppIndicator/SNI, Linux only) - #31
Open
mtb-xt wants to merge 1 commit into
Open
Show a working tray icon on Wayland (AppIndicator/SNI, Linux only)#31mtb-xt wants to merge 1 commit into
mtb-xt wants to merge 1 commit into
Conversation
wx.adv.TaskBarIcon is backed by GtkStatusIcon, which is invisible on Wayland sessions (GNOME, KDE). That makes 'Minimize to System Tray' a one-way trip. Add a pystray/AppIndicator tray that speaks the StatusNotifierItem protocol modern shells render, and select it only on Linux via make_tray_icon() -- Windows and macOS keep the native wx tray untouched, with a fallback to it if pystray isn't available.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #30.
wx.adv.TaskBarIconis backed by GtkStatusIcon (the old X11_NET_SYSTEM_TRAYprotocol), which does nothing on a Wayland session. On GNOME/KDE Wayland the tray icon just never appears, so "Minimize to System Tray" hides the window with no way to get it back.This adds a small
FlooCastTrayIconthat usespystray's AppIndicator backend — it speaks the StatusNotifierItem D-Bus protocol that current shells actually render. It reuses the GLib main loop wx already runs (run_detached()), so there's no second event loop; menu clicks just come back throughwx.CallAfter.I was careful not to touch the platforms where the current tray already works:
make_tray_icon()only picks the new tray on Linux. Windows and macOS keepwx.adv.TaskBarIconexactly as-is.pystrayor the AppIndicator/Ayatana typelib isn't installed, it falls back to the wx tray and prints a note, so the app still starts.The new class exposes the same
restore_window()/Destroy()surface as the existing one, so it's a drop-in at the single construction site.I've been running this on KDE Plasma (Wayland) — the icon shows up and the menu (Show / Minimize / Quit) restores the window reliably.
Extra dependency on Linux only:
pystray, plus theAppIndicator3(orAyatanaAppIndicator3) GI typelib. Happy to adjust naming, the fallback message, or anything else to fit how you'd like it. Thanks!