Bug 464264 - Interoperability with libayatana-appindicator
Summary: Interoperability with libayatana-appindicator
Status: RESOLVED NOT A BUG
Alias: None
Product: plasmashell
Classification: Plasma
Component: System Tray (show other bugs)
Version: 5.18.0
Platform: Other Linux
: NOR normal
Target Milestone: 1.0
Assignee: Plasma Bugs List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-01-14 11:14 UTC by Jorg K
Modified: 2023-01-14 16:58 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jorg K 2023-01-14 11:14:25 UTC
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, or tried to implement, an application indicator in the Linux "systray".

In our testing on Mint/Xfce that works fine, see here for some screenshots:
https://github.com/Betterbird/thunderbird-patches/issues/20#issuecomment-1380109153

However, users of KDE report that:
a) They only get the local icon if they run Betterbird or the two test programs we've supplied as root.
b) KDE doesn't appear to update the text it displays for the item although there is a call to update it.

The code comes from libayatana-appindicator and their PR 17. What we added to Betterbird can be inspected in these three patches.

Adding libayatana-appindicator as 3rd party library to Betterbird:
https://github.com/Betterbird/thunderbird-patches/blob/main/102/features/12-feature-linux-systray.patch

Adding tooltip support as per libayatana-appindicator PR 17:
https://github.com/Betterbird/thunderbird-patches/blob/main/102/features/12-feature-linux-systray-tooltip.patch

The changes in Betterbird to use the new goodness:
https://github.com/Betterbird/thunderbird-patches/blob/main/102/features/12-feature-linux-systray-betterbird.patch
The relevant code in Betterbird that interacts with libayatana-appindicator:
https://github.com/Betterbird/thunderbird-patches/blob/e8b944d0292ac5b473af4cfb7a3378922194513d/102/features/12-feature-linux-systray-betterbird.patch#L272

Any hints or suggestions would be appreciated.
Comment 1 Jorg K 2023-01-14 11:17:42 UTC
Similar bug: Bug 371576.
Comment 3 Fushan Wen 2023-01-14 15:20:24 UTC
ayatana says "Based on KSNI it also works in KDE and will fallback to generic Systray support if none of those are available.",

ayatana will emit NewTitle signal when a new title is set: https://github.com/AyatanaIndicators/libayatana-appindicator/blob/59e472a3caf62f7760f2568729fec8dbc25f8a18/src/app-indicator.c#L978 , and Plasma system tray will also update the title after the signal is received. Not sure it's whose fault.

NewIcon is also emitted: https://github.com/AyatanaIndicators/libayatana-appindicator/blob/59e472a3caf62f7760f2568729fec8dbc25f8a18/src/app-indicator.c#L2032 , and there is no IconPixmap in ayatana. Plasma system tray will try to read the string in "IconName" first, if it's null, the data in "IconPixmap" will be read ( https://invent.kde.org/plasma/plasma-workspace/-/blob/e365c363a7a8e9650798350044d6d348092b3606/applets/systemtray/statusnotifieritemsource.cpp#L311 ). It seems ayatana only supports absolute path, and icon name is not supported. I see no problem so far as the test program also uses absolute paths.

I tend to believe the bug is in ayatana or elsewhere since I use fcitx5, it also uses KSNI and the icon in Plasma system tray can be updated normally.
Comment 5 Fushan Wen 2023-01-14 15:48:19 UTC
(In reply to Jorg K from comment #4)
> Thanks for the comment. There is a bit of discussion going on at
> https://github.com/Betterbird/thunderbird-patches/issues/20#issuecomment-
> 1382814462
> and further down with some test results for
> https://github.com/Betterbird/thunderbird-patches/files/10417402/
> appindicator-dynamic-test.zip
> https://github.com/Betterbird/thunderbird-patches/files/10417451/
> appindicator-dynamic-test-with-tooltip.zip
> 
> Would you be able to run those test programs?

Run with `kdesu ./betterbird-systray-icon`, title and icon are changed as expected. Without root, there is no icon in the system tray.
Comment 6 Jorg K 2023-01-14 15:54:10 UTC
> Run with `kdesu ./betterbird-systray-icon`, title and icon are changed as expected. Without root, there is no icon in the system tray.

OK, thanks. So KDE shows the title "Test Icon Title x", not the specially added tooltip. Well, OK.

One user/tester reported in https://github.com/Betterbird/thunderbird-patches/issues/20#issuecomment-1382303629 that the "number" (in the title) didn't update. Apparently a false report.

So problem b) from comment #0 "KDE doesn't appear to update the text" is a non issue. Good to know.

How about the root requirement? What needs to change to get this going without root?
Comment 7 Jorg K 2023-01-14 16:11:12 UTC
And another question: Is it true that the icon needs to reside in a folder called "icons". In the more recent test programs we made it so, but Betterbird has a different directory structure. This can be tested with an earlier test program https://github.com/Betterbird/thunderbird-patches/files/7781835/betterbird-systray-icon-2.zip. Executable needs to be started in the folder and icon is expected to reside in the same folder, not a subfolder.
Comment 8 Fushan Wen 2023-01-14 16:21:48 UTC
The problem is self->priv->connection is always null when not running as root, so check_connect can't actually register an system tray item. Not sure if the test program uses an too old version of ayatana.

At least this commit is not included.

https://github.com/AyatanaIndicators/libayatana-appindicator/commit/e7acaf90ba791655ce26508c1f5facdea855d2aa
Comment 9 Fushan Wen 2023-01-14 16:30:28 UTC
I ran the new test program and commented out `if (priv->menu == NULL) return;` in check_connect, and now the icon shows as expected.
Comment 11 Jorg K 2023-01-14 16:58:56 UTC
(In reply to Fushan Wen from comment #9)
> I ran the new test program and commented out `if (priv->menu == NULL)
> return;` in check_connect, and now the icon shows as expected.

That works. Only question left is the icon location. In some earlier test programs we didn't have it in an "icons" sub-directory and it still showed. I guess, https://bugs.kde.org/show_bug.cgi?id=371576#c0 "KDE 5.8 now demands custom icon folders have their names ended in 'icons'." isn't correct (any more?).

I think we can close the bug. Thanks a million for your help.