my application uses the Fyne go library to create a systray under Gnome. The snap and the systray works correctly when running in --devmode, but in strict mode certain DBus access signals/calls are denied (please see the log messages below). The systray menu itself gets created, but subsequent DBus calls to add menu items to it fail due to these denials.
I’ve been searching extensively for the correct way to specify the plugs interface configuration but am not entirely sure I got the relevant sections right. Is this configuration supposed to work?
What I wonder is that at present the dbus-dbusmenu plug is not connected (I understand this is not auto connected) but I can’t seem to connect manually either:
$ sudo snap connect myapp:dbus-dbusmenu :dbus
error: snap "snapd" has no slot named "dbus"
I would appreciate any hints, tips or ideas on potential solutions.
In general a snap should not be binding to these dbus names - instead these should already be available via the desktop-legacy and desktop plug - and so you should remove these other two plugs from the snap.
The desktop-legacy plug should be connected automatically as well.
Can you confirm if this is the case? snap connections $SNAP_NAME | grep desktop-legacy
I have now removed the DBus plugs and tested the snap again, it behaves the same way. Some new observations:
the systray works correctly when the snap is run on KDE (Fedora 38).
on GNOME, with gnome-shell-extension-appindicator installed/running, the tray icon does appear but menu items don’t, the icon doesn’t respond to mouse click and the above DENIED messages are logged.
with gnome-shell-extension-appindicator removed, the application gives this error: systray error: failed to register our icon with the notifier watcher (maybe no tray is running?): The name org.kde.StatusNotifierWatcher was not provided by any .service files.
I just tried to take a closer look at this request. When running your snap from here I got a subset of dbus denials different than yours. Could you please confirm that you still get the same denials when running your example snap?
The log output in the OP had a few extra log messages, I have since narrowed it down to the denials that you’re probably seeing in the test case (to confirm, the ones I’m getting below).
@alexmurray Are those rules something we are missing in some interface (maybe to desktop-legacy) or do you think there is a reason to not to include them?
After a deeper check, it seems that the menu path used by fyne, /StatusNotifierMenu, does not match with the menu path allowed by the desktop-legacy interface, /StatusNotifierItem/menu.
I created a fork of the fyne/systray repo and updated the menu path to match with the expected by desktop-legacy interface. Updating your example to use my update fork seems to work perfectly out of the box.
...
source-type: git
source: https://github.com/jslarraz/systray
source-branch: jslarraz-as-dependency
source-subdir: example
If /StatusNotifierItem/menu is the preferred dbus path to locate this menu item you may want to ask fyne upstream to change it (maybe @jamesh can say something here). Otherwise, a better alternative would be to ask fyne upstream to expose this to be configurable by the application developers.