thunderbird-patches
thunderbird-patches copied to clipboard
Systray linux support
I'm using KDE on Arch, but not seeing the systray or anything. Would be a slick feature. I figure the current one is Windows only?
Yes, it's a nice feature, makes my life much easier to see into which folders all the new e-mails were moved via a filter. Betterbird basically enhances Thunderbirds systray display with a correct count and a tooltip showing the individual folder counts.
Looking at our code
@@ -442,16 +444,19 @@ class MailNotificationManager {
if (AppConstants.platform == "win") {
if (!Services.prefs.getBoolPref("mail.biff.show_badge", true)) {
count = 0;
}
if (count > 0) {
tooltip = await l10n.formatValue("unread-messages-os-tooltip", {
count,
});
+ if (this._unreadMailExtra) {
+ tooltip += this._unreadMailExtra;
+ }
}
await WinUnreadBadge.updateUnreadCount(count, tooltip);
}
this._osIntegration?.updateUnreadCount(count, tooltip);
we only add this._unreadMailExtra
to the tooltip in the case of AppConstants.platform == "win"
, which seem to be incorrect. It could also be added for the general case.
Do you get any unread counts anywhere in KDE? I guess they have a thing that looks like the Windows systray. Could you supply a screenshot? If there is an unread count, I could add the tooltip there as well. Would you be willing to try out a corrected version?
Sorry, updateUnreadCount() does nothing on Linux: https://searchfox.org/comm-central/rev/68c2c1641ee0e1c9f320ff304fb8276d540a18ea/mailnews/base/src/nsMessengerUnixIntegration.cpp#18
There isn't any systray on Linux, on Thunderbird too. Gotta use something like BirdTray or Systray-x but both kinda suck.
Well, I guess the problem is, that there isn't one Linux, but there are many, and they use many desktops. On Mint, there is a systray:
But who knows what the API is to drive it. There is also no "minimise to tray"
for Linux, although the old add-on did do something for some Linuxes.
Actually, if I don't work on Betterbird, I work for a company that has a product that puts something into the Linux systray. Let me find out how they do it. No promised made, this doesn't look so good: https://islinuxabout.xyz/systray/
OK, I found it. Our product uses libappindicator with calls like app_indicator_new(), app_indicator_set_status/label/title() and also Gtk calls like gtk_menu_new(), etc. There's even some sample code on how to drive this: https://github.com/linuxmint/libappindicator/blob/master/example/simple-client.c Looks like this could be made to work with medium effort. It's handy that those "app indicators" can also have tooltips, so the whole solution could look a lot like on Windows.
OK, I found it. Our product uses libappindicator with calls like app_indicator_new(), app_indicator_set_status/label/title() and also Gtk calls like gtk_menu_new(), etc. There's even some sample code on how to drive this: https://github.com/linuxmint/libappindicator/blob/master/example/simple-client.c Looks like this could be made to work with medium effort. It's handy that those "app indicators" can also have tooltips, so the whole solution could look a lot like on Windows.
Amazing! Seems promising! I'll maybe research alittle later too. I know Gnome dropped their systray I think but they have addons to bring it back. Think kde and gnome would be the big ones to test on. Maybe xfce too (and any others people can chime in). I can help test and debug any code, littlw code review too even though the code is more unfamiliar territory for me.
I managed to compile the sample code and yes, it displays an icon in the "systray" (seems to be called application indicator area(?)). I'll tweak it a bit later today and give you a test program to see whether you get the icon. If that works, it can be integrated into Betterbird.
Putting up an icon was easy enough
but none of the examples I have show how to do a tooltip. Seems like others have asked the same question:
https://stackoverflow.com/questions/24000840/setting-an-appindicators-tooltip-in-pygtk
They give the impression that it's not supported, however, all the other applications (likely not using app indicators) do show tooltips (as you can see in the image). Sigh.
This stuff is really painful 👎. I've looked at it for hours and here are the findings:
- libappindicator doesn't support tooltips, it's mostly geared around displaying an icon with popup menu.
- I haven't see a way to get the Gtk widget from that icon to call
gtk_widget_set_tooltip_text()
- libappindicator itself uses dbus calls, for example here: https://github.com/linuxmint/libappindicator/blob/a510ab75ba8e0a2f10b5facae430b1ddee2e7b4d/src/app-indicator.c#L2037
- Looks like you need to do all the dbus/Gtk programming yourself if you want a tooltip. I haven't yet found the code for the Mint Notification, Update, Network, Volume Control and Clock widgets, all of which display a tooltip. It looks like they do the Gtk programming themselves, like here: https://github.com/linuxmint/cinnamon/blob/990ceea96aef4b70d26586bf3719a91bf1ed4ccc/files/usr/share/cinnamon/cinnamon-settings/bin/ExtensionCore.py#L1017
- (That notification/indicator area also seems to be called the "panel".)
@Betterbird Excellent work. Painful, hopefully there is a way. KDE's implementation is more straight forward: https://api.kde.org/frameworks/knotifications/html/classKStatusNotifierItem.html https://github.com/ubuntu/gnome-shell-extension-appindicator#missing-features Yeah, see what you're saying with the tooltip. I looked at it for a few hours, but nothing new that would help you beyond what you found for appindicators.
"Excellent work", no result 😢
I think this needs to be written in terms of dbus/Gtk, like Mozilla code does already a bit: https://searchfox.org/mozilla-central/rev/42c90d1426f244db74a164a3121e164f601ad439/widget/gtk/MPRISServiceHandler.cpp#834 - using g_dbus_connection_emit_signal(). You can search there for "dbus" and you will find more dbus stuff in the Mozilla code base. Dbus is also a requirement.
BTW, when I said "Mint", I was talking about my XFCE desktop on Mint. It would be good if we could locate the source code of the Notification, Update, Network, Volume Control and Clock widgets, all of which display a tooltip. The other option would be to drill this open: https://sources.debian.org/src/libayatana-appindicator/.
Update: I'm looking into getting and compiling the Debian source. It should just be a matter of sending a "NewToolTip" signal along with the "NewIcon" signal.
Update 2: Following https://www.linuxfordevices.com/tutorials/debian/build-packages-from-source in the
sudo apt build-dep libayatana-appindicator
I run into
The following packages have unmet dependencies: builddeps:libayatana-appindicator : Depends: debhelper-compat (= 13) E: Unable to correct problems, you have held broken packages.
(or with aptitude
I get this: Unable to satisfy the build-depends: Build-Depends: debhelper-compat (= 13)
).
No idea how to solve this. Strangely enough we have people familiar with the Thunderbird/Mozilla code base, no Linux system hackers 😉
The whole thing is so sad, since this (real screenshot, no mock-up) can be done with little code, cutting out the menu and putting the tooltip directly on the icon requires days of development:
@hockeymikey: Try this on KDE, does it work? You need to extract the PNG next to the executable. betterbird-systray-icom.zip
Through a contact with @sunweaver finally found https://github.com/AyatanaIndicators/libayatana-appindicator and https://github.com/AyatanaIndicators/libayatana-appindicator/pull/17 where tooltips have been added; what a coincidence. I'll check it out.
@Betterbird What am I supposed to do with the zip? Build it and then what?
@hockeymikey : Run the executable betterbird-systray-icon. If you don't trust it, you can compile it yourself, source code and Makefile supplied. You need to unzip the PNG into the same directory. From what I've read, you should see the app icon in the systray/panel. I'm working on getting a version with the tooltip in the right spot, and then integrating that in to Betterbird.
OK, so KDE does show the title from app_indicator_set_title (ci, "Test Inidcator")
(yes, there's a typo) as "sort of" tooltip. I don't see that on my desktop. Click on the icon, then hover the menu item, how does the tooltip look then? And does that tooltip look different to other tooltips? I managed to build https://github.com/AyatanaIndicators/libayatana-appindicator with the help of the maintainer, now I'll add the new tooltip code from the PR.
Sorry, hover the menu item. How does the tooltip look like? See https://github.com/Betterbird/thunderbird-patches/issues/20#issuecomment-1001139034 for how it looks for me.
@hockeymikey: Here's the next one to try. No menu, just the desired tooltip. Works (badly) on Mint XFCE: https://github.com/AyatanaIndicators/libayatana-appindicator/pull/17#issuecomment-1001766352
Here's the archive, executable plus source/makefile: betterbird-systray-icon-2.zip
@Betterbird That second one does nothing for me.
Well, the second one is the one that should display the tooltip. Apparently on Kubuntu it works half-way if you run it as sudo
:
https://www.thunderbird-mail.de/forum/thread/88737-hilfe-beim-testen-des-systray-panel-indicators-auf-linux/?postID=489690#post489690
So far I haven't see a stable solution, so let's see how https://github.com/AyatanaIndicators/libayatana-appindicator/pull/17 works out. The whole thing goes onto the back burner.
The only stable solution I've found so far for Linux is https://github.com/gyunaev/birdtray. You can configure it to use Betterbird. It only supports new message count and not a folder list but that's still a lot better than noting.
Manjaro 21.2.1 GNOME Shell 41.2 GTK 3.24.31
Thanks for the comment, but that's a lot of code and - dare a say - quite some over-engineering (quote: Birdtray checks the unread e-mail status directly by reading the Thunderbird email mork database). The information is there in TB/BB, we just need to display it in the systray which should essentially be <10 lines of code, see https://github.com/AyatanaIndicators/libayatana-appindicator/pull/17#issuecomment-1001766352.
Which is absolutely correct I guess! I'd love having it in Betterbird natively and kick that one out! Just wanted to share it with everyone who's searching for a solution which is working out at the time being.
Hey, I was wondering if integrating systray-x into BB would be a viable solution. At the first look it would only require to add an extension and a separate binary for displaying tray icon and notifications. Though, it doesn't show the tooltip, unread messages count displayed only inside the icon.
Tooltip:
Menu:
New message notifcation:
Tooltip with new message:
I don't think we'll be integrating add-ons. The idea was to provide the same tooltip as on Windows.
Hey, I was wondering if integrating systray-x into BB would be a viable solution. At the first look it would only require to add an extension and a separate binary for displaying tray icon and notifications. Though, it doesn't show the tooltip, unread messages count displayed only inside the icon.
I do like systray-x for thunderbird, it works well, and anything like this would be fine.
I apologize if I didn't understand something. It seems that you are trying to write your own system tray support for each DE? Wouldn't it be better to write a "raw" widget that works directly with X11, like frameworks like Qt do. Here you can see how it works: https://github.com/qt/qtbase/blob/5.15.2/src/widgets/util/qsystemtrayicon_x11.cpp
Then you do not have to check the widget in each DE. I, for one, have no problem using applications written in Qt while running Xfce. Conversely, when I work in KDE, I have no problems with applications written in GTK.