Closed Betterbird closed 1 year ago
Yes, I actually got to know about Betterbird when I was looking for good alternatives for Thunderbird closing to tray on linux. MinimizeToTray Reanimated has versions that work with Thunderbird 60.0 - 63.*, I think it is not maintained anymore. I used to use Birdtray, but had some issues with it. I am currently using SysTray-X, and it is fine on X11 but does not work on Wayland. Since now we have a tray icon that is working properly on Linux systems, I wish that Betterbird could support close to tray. It seems more attainable now.
I would love to have a "close to tray" option, and even nicer that a click on the tray icon would minimize to tray if betterbird is open and show betterbird if it was closed.
So we've made a start here: https://github.com/Betterbird/thunderbird-patches/blob/main/102/features/13-feature-linux-minimise-to-tray.patch
Sadly we ran into https://github.com/AyatanaIndicators/libayatana-appindicator/issues/4: Currently there is no way to get notified for clicks onto the app indicator, that is, the system tray icon. With the patch applied, the window is hidden and the systray icon is displayed, the "minimise to tray" effect, but clicking the icon doesn't maximise/unhide again since we can't get a click event/signal.
We'll see how this can be solved in libayatana-appindicator.
How about adding a menu instead with a "Show/Hide" button? That was working out even for GNOME in the official appindicator demo.
How about adding a menu instead with a "Show/Hide" button? That was working out even for GNOME in the official appindicator demo.
Well, any additional text strings bring localisation issues. Two clicks instead of one are also clumsy and they are also different to what the Windows version does.
Yes, people have been adding menus to work around the non-ability of getting the clicks, see here for example: https://bugzilla.redhat.com/show_bug.cgi?id=1319869 https://bugs.launchpad.net/ubuntu/+source/libappindicator/+bug/1910521 https://github.com/electron/electron/pull/35319/commits/f7adf8501fdd33b4b3c13649905dea977019eb59 <-- this shows the dummy menu.
We're in a better position: We use a fork of the library, so with the right knowledge (which we don't have) we could just add code for the click event.
I landed here after installing Betterbird on linux and finding out there is still active development in trying to make a systray fully work (thanks!). I will just leave my comment here for anybody else that is in my same situation and immediately wants something that gives at least some basic functionality: gyunaev/birdtray fully works with Betterbird, once you set the correct path to the betterbird executable and use Betterbird
as the window pattern.
Yes, we have a patch that works in minimising the windows to the tray: https://github.com/Betterbird/thunderbird-patches/blob/main/102/features/13-feature-linux-minimise-to-tray.patch Sadly due to functionality missing from the upstream libayatana-appindicator, we can't get clicks onto the system tray icon to restore the window, so with the patch it's: Minimise once, not able to restore, kill the process ðŸ˜
We made an effort here https://bugs.kde.org/show_bug.cgi?id=465438 to get some idea on how to implement that, so far to no avail. We need to start an initiative on one of the KDE mailing lists as suggested in the bug, kde-devel@kde.org.
I found that the Qt library provides the QSystemTrayIcon Class https://doc.qt.io/qt-6/qsystemtrayicon.html, which provides an icon for an application in the system tray.
The QSystemTrayIcon class can be used on the following platforms: All supported versions of Windows. All Linux desktop environments that implement the D-Bus StatusNotifierItem specification, including KDE, Gnome, Xfce, LXQt, and DDE. All window managers and independent tray implementations for X11 that implement the freedesktop.org XEmbed system tray specification. All supported versions of macOS.
It has an "activated" signal which gives an "ActivationReason", which can be of type "QSystemTrayIcon::Trigger": The system tray entry was clicked
@Betterbird do You know the KDocker?
I'm using it to provide a tray icon to Betterbird and Thunderbird.
Maybe You can use something from the KDocker code to provide a decent solution.
Thanks for the suggestion. We're using AyatanaIndicators/libayatana-appindicator, and that's not moving forward, see latest comment here: https://github.com/AyatanaIndicators/libayatana-appindicator/issues/4#issuecomment-1539138232
@Betterbird do You know the KDocker?
I'm using it to provide a tray icon to Betterbird and Thunderbird.
Maybe You can use something from the KDocker code to provide a decent solution.
KDocker does not support Wayland atm, so it’s not very future-proof. I would rather repeat my suggestion: QSystemTrayIcon. I understand that it would take some work to replace the existing code that uses libayatana-appindicator though.
Activation support for system tray icons has arrived, see https://github.com/AyatanaIndicators/libayatana-appindicator/pull/71.
Sadly it's only working for KDE, so we can implement "minimise to tray" on KDE only. Thoughts? Anyone willing to test?
I'm willing to test this on KDE
Thanks, I'll get it done in the next 48 hours. We already have a patch that is 95% complete: https://github.com/Betterbird/thunderbird-patches/blob/main/102/features/13-feature-linux-minimise-to-tray.patch
OK, like on Windows, you can now enable this under "System Integration":
We tested the minimise part, we can't test the restore part since we currently don't have KDE. It's possible that it crashes on restore, that is, click onto the system tray icon after minimising it. If it's not minimised, a click onto the system tray icon should just bring the window to the foreground.
Please run Betterbird from a terminal window, if it doesn't even mininise to tray, it will tell you why. Download: http://www.betterbird.eu/downloads2/betterbird-115.1.1-bb9-minimise-to-tray.en-US.linux-x86_64.tar.bz2
P.S.: In case anything works, does a maximised window get restored as non-maximised? That could be fixed.
Thank you for that. It works. The only catch is that I have to click twice on the icon before the window is actually restored. It seems that the first time it tries to restore but then immediately goes back to tray. The second time, the window is restored fine. https://github.com/Betterbird/thunderbird-patches/assets/10415894/59ae1590-bf2d-4f5f-967f-42cbd8f4966d
PS: with the extension "Minimize on Close", we also get the same behavior on close: close to tray, which is nice
PPS: my first test and video were in X11. It also works the same in Wayland
PPPS: yes, maximised window get restored as non-maximised
Thanks for testing. I can't see the "first time it tries to restore but then immediately goes back to tray", maybe it's not captured in the video.
There was a question you didn't answer: If it's not minimised, a click onto the system tray icon should just bring the window to the foreground. But I realise that for testing that, you need to set pref mail.biff.show_tray_icon_always first.
Looks like I have to get a KDE desktop somehow 😞.
P.S.: OK, got a KDE desktop now. So yes, if not minimised, a click on the "always on" icon activates the window. That's good. I can also see the "failed" attempt to restore which is not in the video.
It works perfectly in KDE on X11 and Wayland. Just one question: is there an option to start betterbird minimized in the tray?
Yes, set pref mail.startupMinimized (no UI for that one). In our testing that also works, but we've just made another tweak to make it more stable. Let me know if it doesn't work and I'll send another binary.
I'll also leave my 2 cents here. Disclaimer: I know it should only work for KDE but I tried it with GNOME explicitly (by adjusting the config value). Even if there are no tooltips for GNOME I'd like to have this as feature. This first take was very glitchy and not reliable at all. This one has reproducible behavior tho.
Here is a desktop recording: https://github.com/Betterbird/thunderbird-patches/assets/14966472/edaf9fee-258d-4204-bf67-5e123fbe3f8a
Gotta love those different desktops. Did the first version ever restore the window without having to click on the taskbar? We changed the code to restore the window, the first code was more Gtk-ish, so perhaps this works better.
The aim is to ship this in 115.2.0 in a few days, so there's not much time for experiments. I can compile a "take 3" later on for you to check.
P.S.: what string did you add to the pref? "gnome" or something longer?
The first one was very unreliable as I said, so I can't really tell you what it did when 😄 Yes I just replaced "kde" with "gnome" in my case as I didn't know if adding works with commas or something different.
Commas or spaces to separate, or replace. But the console message said to add "gnome"?
Yes, just re-checked by removing it again.
Betterbird: Window NOT minimized to system tray!
You are using desktop environment gnome.
Minimize to system tray is only supported for these desktops:
kde.
As an experiment, add gnome to preference
mail.minimizeToTray.supportedDesktops.
You might not be able to maximize the window again and
will have to kill Betterbird.
USE AT YOUR OWN RISK! If successful, contact support@betterbird.eu
FYI, there is code in Mozilla that checks for gnome and it's different to checking kde: https://searchfox.org/mozilla-central/rev/7042a4a444f040ed87045c216f97cb73ce9410df/widget/gtk/WidgetUtilsGtk.cpp#485,491 For KDE they compare to "kde", for Gnome they search the string "gnome" in the desktop environment, as if the system returned "gnomeXYZ". Anyway, mostly irrelevant here.
Now I've added this code:
void* gtkWidget = widget->GetNativeData(NS_NATIVE_SHELLWIDGET);
if (gtkWidget) gtk_window_present(GTK_WINDOW(gtkWidget));
widget->SetFocus(nsIWidget::Raise::Yes, mozilla::dom::CallerType::System);
Take 1 had the first two lines, take 2 the last one, take 3 has all of them. Still works on KDE. I don't know what else to do if the windows manager doesn't react to the appropriate calls.
If that works, I can add "gnome" to the pref and advertise the feature for KDE and Gnome.
Instead of gtk_window_present()
https://docs.gtk.org/gtk4/method.Window.present.html, we can also try gtk_window_deiconify()
https://docs.gtk.org/gtk3/method.Window.deiconify.html (or both):
https://searchfox.org/mozilla-central/rev/7042a4a444f040ed87045c216f97cb73ce9410df/widget/gtk/nsWindow.cpp#2832
So this has "deiconify".
@felixoi, @Zahrun: Do you see any difference between take 2, 3 and 4? Help select the winner, unless they are all losers on Gnome.
I installed sudo apt install vanilla-gnome-desktop
. So where do I get the "system tray" from? Following https://linuxiac.com/how-to-enable-system-tray-icons-in-gnome/, I installed the "Extension Manager" and then "AppIndicator and KStatusNotifierItem Support". Was that right? For activation of BB I had to triple click and all the rest was also very flaky. The Gnome I saw also didn't have a taskbar with icons like in your video.
I'm using https://extensions.gnome.org/extension/1160/dash-to-panel/ which is pretty popular. For Manjaro for example it's the default extension if you want to have a toolbar. You are right, the tray icons are from the plugin you mentioned. Dash to Panel is adding the taskbar at the bottom itself.
Take 3 works the best for my GNOME installation currently. These points still stand tho:
The application opens back in the foreground with take3 also. With take4 its broken again.
Yes, set pref mail.startupMinimized (no UI for that one). In our testing that also works, but we've just made another tweak to make it more stable. Let me know if it doesn't work and I'll send another binary.
Awesome, it works.
@felixoi, @Zahrun: Do you see any difference between take 2, 3 and 4? Help select the winner, unless they are all losers on Gnome.
I don’t see any difference between take 2, 3, and 4 on KDE.
Take 3 works the best for my GNOME installation currently. These points still stand tho:
1. Only the first time it's working with one click, after having it opened back from tray once I'll have to double click the tray icon for the next times 2. Seems like it's always opening to the same location on the screen, not the one selected before
Point 2. also happens in KDE. The window gets restored to the same size but at the center of the screen instead of at the previous location. Personally I don’t mind.
I also noticed that when Betterbird is minimised to tray, if I call betterbird from Latte dock or simply by the application launcher (which is equivalent to just run the betterbird executable), it does not get restored, it actually does nothing. Maybe that would be a nice additional feature.
Thanks again for implementing the long awaited minimise to tray feature. Works pretty great on KDE.
OK, I went back to the code from "take 3" on Gnome, and it works pretty well. I can't detect any activity with a single click, for me to activate is always via double-click. So I'll ship with the code from "take 3" and gnome enabled by default.
Also see out "expert tips" page now:
The following is supported:
OS/Desktop | System tray | System tray always | Tooltip with folder list | Minimize to tray -- | -- | -- | -- | -- Windows | Yes | Yes | Yes | Yes Linux/KDE | Yes | Yes | Yes | Yes Linux/Gnome | Yes | Yes | No | Yes Linux/Xfce | Yes | Yes | Yes | No "Minimize to tray" on Linux from version 115.2.0.Relevant preferences:
UPDATE: Cinnamon and Mate also don't support the necessary activation for "minimize to tray".
I'm trying to understand why does it not work on MATE - this is the game-breaker that prevents me from upgrading from Thunderbird 45.
UPDATE: Cinnamon and Mate also don't support the necessary activation for "minimize to tray".
You mean that the particular library you are using (libayatana
?) does not catch events from Marco, correct? Clicking tray icons works just fine with any other app, including old Thunderbird with Firetray. I assume that's because they are using a different library, is that right? Could that maybe be used as a reference?
I couldn't find any relevant code in Firetray - I guess they are using some higher-order facilities than doing it in the C level. But perhaps the most useful specimen to dissect would be https://github.com/ysard/mintrayr - that's in C, and it seems to use plain GTK. I can't make heads or tails of the code however.
Please follow https://github.com/AyatanaIndicators/libayatana-appindicator/pull/71
It's working now for KDE, Gnome and Xfce.
Solution found! In https://github.com/mate-desktop/mate-panel/issues/1049 .
gsettings set org.mate.panel enable-sni-support true
If your Betterbird refuses to minimize to tray because it suspects that you won't be able to get it back (check its output console), then add mate
to mail.minimizeToTray.supportedDesktops
.
Thanks, so we've added this to the documentation:
The following is supported:
OS / Desktop | System tray | System tray always | Tooltip with folder list | Minimize to tray -- | -- | -- | -- | -- Windows | Yes | Yes | Yes | Yes Linux / KDE | Yes | Yes | Yes | Yes Linux / Gnome | Yes | Yes | No | Yes(*) Linux / Cinnamon | Yes | Yes | Yes | No Linux / Mate | Yes | Yes | Yes | Yes(**) Linux / Xfce | Yes | Yes | Yes | Yes "Minimize to tray" on Linux from version 102.5.0 and 115.2.0. 102.5.0 only supports KDE and Gnome.(*) For Gnome you need to install the "AppIndicator and KStatusNotifierItem Support" extension.
(**) For the Mate desktop you need to run gsettings set org.mate.panel enable-sni-support true and then restart.
In Betterbird you need to add mate to the preference mail.minimizeToTray.supportedDesktops.
Thank you for your work, @Betterbird. I now completely replaced thunderbird by betterbird on my system, since the former lacked the minimise to tray feature for too many years. I sent a small donation to you via SEPA.
Hey there, new betterbird user on Fedora KDE 39. I am using the flatpak. I cannot get minimize to tray working. After I hit minimize, I still see the app icon in the task manager. I did a reinstall, but now the the tray icon never shows, even when it is checked.
How do I debug this?
After I hit minimize, I still see the app icon in the task manager.
OK, so the "task manager" is what Windows calls "task bar":
https://userbase.kde.org/Plasma/Tasks
And this is set?
I did a reinstall, but now the the tray icon never shows, even when it is checked.
What did you re-install? What is checked? The option to show the tray icon:
What happens if you set pref mail.biff.show_tray_icon_always
?
What did you re-install
I reinstalled betterbird from flatpak store
When maximized left is the icons-only task manager thingy, and the right-most one is the tray icon. I edited the picture to remove the empty space in between.
This is betterbird minimized
mail.biff.show_tray_icon_always I set that to true, and I can see the tray icon when minimized or maximized. Clicking on the icon does not maximize the window when it is minimized. When minimized, both the tray icon and task manager icons are shown (the 4th image)
What did you re-install
I reinstalled betterbird from flatpak store
When maximized left is the icons-only task manager thingy, and the right-most one is the tray icon. I edited the picture to remove the empty space in between.
This is betterbird minimized
mail.biff.show_tray_icon_always
I set that to true, and I can see the tray icon when minimized or maximized. Clicking on the icon does not maximize the window when it is minimized. When minimized, both the tray icon and task manager icons are shown (the 4th image)
I wanted to check if it was a flatpak or some other issue, so I downloaded the tarball to try and eliminate all other variables.
I also deleted the ~/.thunderbird
folder. Then ran betterbird
, and betterbird-bin
. When X11 is used, minimizing the app correctly removes it from the task manager and shows the tray icon.
With wayland enabled with MOZ_ENABLE_WAYLAND=1
, I am able to reproduce the above issue. I want to use wayland because of better trackpad gesture support.
If I see it correctly, Wayland isn't fully supported by the Mozilla platform, see all the "Depends on" in this meta bug: https://bugzilla.mozilla.org/show_bug.cgi?id=635134
That the window doesn't minimise is due to the fact that internally a "sizemodechange" is not received. We debugged this with another BB user, who in the end reported this upstream bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1872790
You can repeat the steps in the description of this bug, that is, paste
top.window.addEventListener("sizemodechange", () => console.log("sizemodechange received"))
into the error console and see what gets logged when minimising the window.
top.window.addEventListener("sizemodechange", () => console.log("sizemodechange received"))
Yeah it doesn't print anything :/
This doesn't seem to work on tiling window manager (namely, XMonad). Clicking the icon does not do anything, closing the window, well, closes Betterbird instead of minimizing to tray. Welp, back to Thunderbird then.
Do you use Wayland? Anyway, TB doesn't offer the feature.
Nope, plain old X11. I know, but neither does BB.
What you write is rather irritating. Yes, BB does offer system tray support incl. minimise to tray on known configurations and it's also documented at https://www.betterbird.eu/expert-tips/
The following is supported:
OS / Desktop | System tray | System tray always | Tooltip with folder list | Minimize to tray -- | -- | -- | -- | -- Windows | Yes | Yes | Yes | Yes Linux / KDE | Yes | Yes | Yes | Yes Linux / Gnome | Yes | Yes | No | Yes(*) Linux / Cinnamon | Yes | Yes | Yes | No Linux / Mate | Yes | Yes | Yes | Yes(**) Linux / Xfce | Yes | Yes | Yes | Yes "Minimize to tray" on Linux from version 102.5.0 and 115.2.0. 102.5.0 only supports KDE and Gnome.(*) For Gnome you need to install the "AppIndicator and KStatusNotifierItem Support" extension. Double-click to activate.
(**) The Mate desktop is supported from BB 115.3.1-bb14 build after 2 October 2023.
Relevant preferences:
You will understand that it's impossible to support all possible Linux variations.
Which desktop are you using and have you started BB from the command line to see which desktop it reports. If that's not in the list of supported desktops, it won't work.
@Betterbird He just means, "Since it's not working for me, and this is the only feature I needed, I'll stick with the unpatched Thunderbird for now". :slightly_smiling_face:
I know what he means. But it's written as a threat "back to Thunderbird then" and a false statement "neither does BB".
@Betterbird I'm sorry I've offended you, I was just stating the fact that I'm not going to use your product since it does not work for me and, I guess, for a whole lot of professional Linux users since tiling window managers occupy a lot of places in the lists of most popular desktop environments, e.g. this one — it even has one on 2nd place. Is it ok for me to open separate issue regarding tray icon on tiling window managers and help with resolving it?
From https://github.com/Betterbird/thunderbird-patches/issues/20#issuecomment-1383105403:
Check this question and this answer. It's now tracked here: https://bugzilla.mozilla.org/show_bug.cgi?id=1627479 Getting the indicator in the systray (Issue #20) was hard enough and still doesn't work fully on Gnome. Hiding the taskbar "button" to instead show the icon seems even harder. Or is there some API that can do it? Or maybe the code from this add-on https://addons.thunderbird.net/en-GB/thunderbird/addon/minimizetotray-reanimated/ could be used.