Bug 465438 - Request for help to get some handle to a system tray icon created with libayatana-appindicator
Summary: Request for help to get some handle to a system tray icon created with libaya...
Status: RESOLVED NOT A BUG
Alias: None
Product: plasmashell
Classification: Plasma
Component: System Tray (show other bugs)
Version: 5.26.0
Platform: unspecified Linux
: NOR wishlist
Target Milestone: 1.0
Assignee: Plasma Bugs List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-02-07 18:24 UTC by Jorg K
Modified: 2023-09-12 08:03 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jorg K 2023-02-07 18:24:49 UTC
This is not a bug report but a request for help. Sorry if this is the wrong way to go about it.

I'm the project leader of Betterbird (www.betterbird.eu). In our feature request https://github.com/Betterbird/thunderbird-patches/issues/20 we've implemented notifications on the systray via https://github.com/AyatanaIndicators/libayatana-appindicator. We've also picked up their https://github.com/AyatanaIndicators/libayatana-appindicator/pull/17. The result looks pretty good in KDE, see here:
https://user-images.githubusercontent.com/10415894/212687109-10227dcf-3cbf-44a8-81db-cbaaf3f25a9e.png
(the resolution of the icon was fixed later, now using SVG).

So far so good.

The feature request we have is https://github.com/Betterbird/thunderbird-patches/issues/111. What we need to implement this is https://github.com/AyatanaIndicators/libayatana-appindicator/issues/4, see especially here:
https://github.com/AyatanaIndicators/libayatana-appindicator/issues/4#issuecomment-1383906148

In short, we'd like to connect a listener (receive a callback) when the user clicks on the icon in the systray. The icon is created in libayatana-appindicator here
https://github.com/AyatanaIndicators/libayatana-appindicator/blob/f225dccbd82f48bb1ab10767b9b074e24fedb0f3/src/app-indicator.c#L2032
via `g_dbus_connection_emit_signal(..., "NewIcon", ...)` and it appears that no handle to it is returned.

Can you help us to get a grip on that icon so we get notified when it's clicked?
Comment 1 Bug Janitor Service 2023-02-07 18:33:27 UTC
Thank you for the bug report!

However Plasma 5.18.0 is no longer supported by KDE; supported versions are 5.24, and 5.26 or newer.
Your distribution is responsible for providing support for older versions of KDE software.

Please do one of the following:
- Upgrade to a supported version and see if the issue is still relevant
- Report the issue to your distribution
Comment 2 Tobias Fella 2023-02-07 19:22:47 UTC
If I understand the D-Bus protocol correctly, what you want is to do something (i.e. raise window) in the activate function [0] of the org.kde.StatusNotifierItem protocol, which looks like what you're doing in the comment you linked. For some reason this function seems missing from ayatana's version of the dbus XML [1] - I don't know how their dbus code works, maybe that could be the problem?

[0] https://invent.kde.org/frameworks/knotifications/-/blob/master/src/org.kde.StatusNotifierItem.xml#L63
[1] https://github.com/AyatanaIndicators/libayatana-appindicator/blob/master/src/notification-item.xml
Comment 3 Jorg K 2023-02-07 19:42:01 UTC
Thanks for the comment. I'm really a Thunderbird/Betterbird/Mozilla programmer (mostly on Windows), so please excuse the ignorance. We've integrated libayatana-appindicator and one of their PRs into Betterbird, then patched it even further thanks to the advice received in bug 464264 comment #9.

Yes, we want to "unhide" a window when a click on the indicator is received. So if I understand your comment correctly, KDE already provides a notification for that event, only that it's not hooked up in the libayatana-appindicator implementation. That's totally possible. Are you aware of other applications which successfully listen to such notifications? We could learn from them.
Comment 4 Nate Graham 2023-02-07 20:22:07 UTC
Feel free to keep chatting, but I'm closing the bug so it doesn't appear in new bug lists, because technically Bugzilla is not the place for development assistance. If the conversation trails off here, I would recommend continuing it at kde-devel@kde.org.
Comment 5 Jorg K 2023-02-07 20:39:35 UTC
Thanks and apologies for the misuse of your bug tracker! Will use the mailing list in the future.
Comment 6 Konrad Materka 2023-02-12 13:05:52 UTC
IIRC this is a limitation in appindicator lib. This "Activate" operation was never implemented, probably because it was not needed in Unity/Gnome desktop. It was long time I used it last time, but I think status notifiers are implemented differently there - they are integrated into task manager. So task manager handles left click (to show/minimize app) and "Activate" part of SNI is never used.
Comment 7 Jorg K 2023-02-12 13:36:19 UTC
Yes, "activate" was never implemented, see https://github.com/AyatanaIndicators/libayatana-appindicator/issues/4, but how would we go about implementing it.
Comment 8 Jorg K 2023-09-12 08:03:58 UTC
Just to close the circle here, https://github.com/AyatanaIndicators/libayatana-appindicator/pull/71 implements "activation" satisfying https://github.com/AyatanaIndicators/libayatana-appindicator/issues/4. That initially worked for KDE and Gnome, then the Xfce developer showed up on the PR and posted some code to make it work for Xfce as well. Some user suggested a setting to make it work for Mate, but that doesn't work for us.

In summary, Betterbird shows a system tray icon via libayatana-appindicator and clicking it, activates the application in KDE, Gnome and Xfce. Activation is a little patchy, on KDE sometimes the window is raised, sometimes the taskbar (panel?) button is highlighted. We might file another ticket for that. We're tracking this in https://github.com/Betterbird/thunderbird-patches/issues/202.