unix: add SetIconTheme and SetIconThemePath for SNI icon theme support - #120
Open
vasyvasilie wants to merge 1 commit into
Open
unix: add SetIconTheme and SetIconThemePath for SNI icon theme support#120vasyvasilie wants to merge 1 commit into
vasyvasilie wants to merge 1 commit into
Conversation
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.
Problem
On MATE desktop (with
mate-indicator-applet) and some GNOME setups, theStatusNotifierItem spec allows displaying the icon via
IconPixmap(raw ARGBdata) or via
IconName+IconThemePath(XDG icon theme lookup). Manyindicator applets on these desktops prefer
IconNameand either ignore orpoorly render
IconPixmap.Currently
systrayhardcodesIconName: ""andIconThemePath: ""asnon-writable properties in
createPropSpec(), with no public API to changethem. There is also no way to make
IconPixmapreturn an empty array — italways calls
convertToPixels(t.iconData)even when you'd rather have the DE(Desktop Environment) fall back to
IconName.Real-world impact
I built an ap using Fyne + systray. The app switches tray icons between
two states. On MATE with
mate-indicator-applet:IconPixmapis sent asa(iiay)with raw bytes, but the applet renders ablank/invisible icon
busctl get-propertythatIconName = ""andIconThemePath = ""at all timessystray.SetIcon(bytes)updatesIconPixmapbut thetray stays blank
The only working solution for MATE is:
Changes
SetIconName(name string)— setsIconNameDBus property and emitsNewIconsignal to notify the hostSetIconThemePath(path string)— setsIconThemePathDBus propertyiconPixmapValue(iconData []byte) []PX— returns empty[]PX{}when noicon data (allows DE to fall back to
IconName); returns normal pixmapotherwise
createPropSpec:IconNameandIconThemePathnow initialized frompackage-level vars and marked
Writable: trueBackward compatibility
Fully backward compatible. Default values of
iconNameandiconThemePathare
""— existing behavior unchanged.iconPixmapValueonly returns emptyarray when
iconDatais nil/empty.Environment
mate-session-manager 1.26.1-2build2)mate-indicator-applet 1.26.0-1build3via Ayatana indicatorslibayatana-appindicator3-1 0.5.93-1build3libayatana-indicator3-7 0.9.4-1build1libdbusmenu-gtk3-4 18.10.20180917~bzr492+repack1-3.1ubuntu5org.kde.StatusNotifierWatcher(ayatana-indicator process)Diagnostics
Other apps on the same system (e.g.
blueman-tray) correctly useIconNamewithout
IconPixmap:$ busctl --user get-property org.blueman.Tray /org/blueman/sni \ org.kde.StatusNotifierItem IconName s "blueman-active"Our app before this patch (systray sets only
IconPixmap,IconName = ""):$ busctl --user get-property org.kde.StatusNotifierItem-{PID}-1 \ /StatusNotifierItem org.kde.StatusNotifierItem IconName s "" $ busctl --user get-property org.kde.StatusNotifierItem-{PID}-1 \ /StatusNotifierItem org.kde.StatusNotifierItem IconPixmap a(iiay) 1 22 22 0 0 0 0 ... ← present but ignored by MATE/Ayatana → blank iconAfter this patch (
SetIconName("link")+SetIconThemePath("/path/to/resources")):$ busctl --user get-property org.kde.StatusNotifierItem-{PID}-1 \ /StatusNotifierItem org.kde.StatusNotifierItem IconName s "link" $ busctl --user get-property org.kde.StatusNotifierItem-{PID}-1 \ /StatusNotifierItem org.kde.StatusNotifierItem IconPixmap a(iiay) 0 ← empty, Ayatana falls back to IconName → icon displayed correctlyTesting
Tested on MATE desktop with
mate-indicator-applet(SNI viaorg.kde.StatusNotifierItem). Icon switches correctly between states onSetIconNamecalls, verified viabusctl introspect.