Fix missing KDE tray icon by preferring Ayatana AppIndicator (#621)
* Fix missing KDE tray icon by preferring Ayatana AppIndicator Fedora and Arch installs pull libappindicator-gtk3, Canonical's original AppIndicator library that hasn't had a real release since ~2013. It loads fine and Indicator.new_with_path()/set_status() run without raising, but it never registers a StatusNotifierItem with KDE's StatusNotifierWatcher, so the tray icon silently never shows up on Plasma. Confirmed on Fedora 44 / Plasma 6.7 by checking RegisteredStatusNotifierItems over D-Bus directly before and after the fix. The actively maintained Ayatana fork registers correctly and is already what the Debian, Ubuntu, openSUSE and Gentoo branches of install.sh prefer. Reorder the gi import in tray_indicator.py to try AyatanaAppIndicator3 first and fall back to the legacy AppIndicator3 typelib only if neither Ayatana variant is available. Update install.sh so Fedora and Arch installs pull the Ayatana package too, via a shared install_preferred_appindicator() helper that falls back to the legacy package if Ayatana isn't in the repos (e.g. RHEL/CentOS without EPEL). * Add tests for the AppIndicator/Ayatana import fallback chain The reordered try/except in tray_indicator.py wasn't exercised by the existing tests: they replace gi.repository with a MagicMock, which auto-creates any attribute on access and so can never raise the ImportError the fallback chain is built to catch. Add a small test class that swaps in a plain object exposing only a chosen subset of AppIndicator symbols, so importing anything else raises a real ImportError, and verify each of the three branches (Ayatana, lowercase Ayatana variant, legacy AppIndicator3) resolves correctly. * Retry Ayatana install even when legacy AppIndicator is already present install_preferred_appindicator() previously skipped the Ayatana install whenever either package was already present, so re-running install.sh on an existing Fedora/Arch setup with libappindicator-gtk3 from a prior install would never pick up Ayatana, leaving the KDE tray broken for exactly the users this fix targets. Now it only short-circuits when Ayatana itself is installed, tries Ayatana first regardless of legacy presence, and only falls back to a warning about the already-installed legacy package if the Ayatana install fails. --------- Co-authored-by: Jatin K Malik <jatinkrmalik@gmail.com>
This commit is contained in:
co-authored by
Jatin K Malik
parent
5eff933d73
commit
afc4b37c80
@@ -14,16 +14,21 @@ import gi
|
||||
|
||||
# Import GTK
|
||||
gi.require_version("Gtk", "3.0")
|
||||
# Prefer Ayatana AppIndicator: it is the actively maintained fork and the one
|
||||
# most distros ship for KDE/SNI compatibility. The original Canonical
|
||||
# AppIndicator3 (unmaintained since ~2013) can be present alongside it (e.g.
|
||||
# Fedora's libappindicator-gtk3) but fails to register a StatusNotifierItem
|
||||
# on modern KDE Plasma, leaving the tray icon invisible with no error logged.
|
||||
try:
|
||||
gi.require_version("AppIndicator3", "0.1")
|
||||
from gi.repository import AppIndicator3
|
||||
gi.require_version("AyatanaAppIndicator3", "0.1")
|
||||
from gi.repository import AyatanaAppIndicator3 as AppIndicator3
|
||||
except (ImportError, ValueError):
|
||||
try:
|
||||
gi.require_version("AyatanaAppIndicator3", "0.1")
|
||||
from gi.repository import AyatanaAppIndicator3 as AppIndicator3
|
||||
except (ImportError, ValueError):
|
||||
gi.require_version("AyatanaAppindicator3", "0.1")
|
||||
from gi.repository import AyatanaAppindicator3 as AppIndicator3
|
||||
except (ImportError, ValueError):
|
||||
gi.require_version("AppIndicator3", "0.1")
|
||||
from gi.repository import AppIndicator3
|
||||
|
||||
from gi.repository import GdkPixbuf, Gio, GLib, GObject, Gtk
|
||||
|
||||
|
||||
Reference in New Issue
Block a user