mozilla / sumo-kb

Repo to host snippet codes for Mozilla Support Knowledge Base articles
https://github.com/mozilla/sumo-kb
6 stars 4 forks source link

Thunderbird.desktop file leads to duplicate icons in GNOME Dock when pinned #6

Open philg-dev opened 1 month ago

philg-dev commented 1 month ago

I've installed Thunderbird with the instructions on the mozilla KB.

The Thunderbird.desktop from this repository, which is part of the instructions, has a small, but annoying issue with the GNOME Dock: When you add Thunderbird to your favorite applications it gets pinned to the Dock. That's especially useful, when you want to use simple shortcuts to switch between your favorite apps in a consistent manner (e.g. <Super> + 1~9 to access the applications in the Dock).

However with the given Thunderbird.desktop file, when I open Thunderbird and I confirm my master password prompt, the Thunderbird main window will open with a separate icon in the Dock (window title "thunderbird-esr"), whereas the pinned desktop icon is properly titled "Thunderbird Mail".

The problem is, that I switch focus to my open Thunderbird with <Super> + 2 anymore in that case because the pinned desktop icon appears "inactive", since the main window is in a different spot instead. So that breaks my usual workflow a lot.

Solution

I was digging deeper on the problem and I could solve the issue by adding the following property to the Thunderbird.desktop file:

StartupWMClass=thunderbird-esr

(Edited after the discussion below. Before the discussion my solution was StartupWMClass=Mail, but it turned out that only works on X11, but not on Wayland.)

Resources / Approach

To get to this solution, I inspected the X-Window properties of both the master password prompt and the Thunderbird main window with the xprop command.

The Thunderbird master password prompt always has: WM_CLASS = "Thunderbird", "thunderbird-esr"

The Thunderbird main window always has: WM_CLASS = "Mail", "thunderbird-esr"

Maybe somebody who is more knowledgeable on this topic could enlighten us why and how my solution works. I only know that it works for me and I have a general suspicion on how it works.

I came across a similar issue that has been fixed for VS Code to get to this solution.

Assumption on how it the problem and solution works


If anybody can confirm my theory or suggest a more solid solution, we could make a pull request in order to get the fix out to everybody.

lamyergeier commented 1 month ago

@philg-dev I face the exact problem although I don't use Master password.

I added StartupWMClass=Mail to my thunderbird.desktop but it didn't help:

cat /usr/local/share/applications/thunderbird.desktop
[Desktop Entry]
Encoding=UTF-8
Name=Thunderbird Mail
Comment=Send and receive mail with Thunderbird
GenericName=Mail Client
Keywords=Email;E-mail;Newsgroup;Feed;RSS;Calendar;Contact
Exec=/mnt/Data/opt/bin/thunderbird %u
Terminal=false
X-MultipleArgs=false
Type=Application
Icon=/mnt/Data/opt/Setup/Thunderbird/thunderbird-128/thunderbird/chrome/icons/default/default128.png
Categories=Application;Network;Email;
MimeType=x-scheme-handler/mailto;application/x-xpinstall;
StartupNotify=true
Actions=Compose;Contacts;Calendar;ProfileManager
StartupWMClass=Mail

[Desktop Action Compose]
Name=Compose New Message
Exec=/mnt/Data/opt/bin/thunderbird -compose

[Desktop Action Contacts]
Name=Contacts
Exec=/mnt/Data/opt/bin/thunderbird -addressbook

[Desktop Action Calendar]
Name=Calendar
Exec=/mnt/Data/opt/bin/thunderbird -calendar

[Desktop Action ProfileManager]
Name=Profile Manager
Exec=/mnt/Data/opt/bin/thunderbird --ProfileManager
philg-dev commented 1 month ago

@lamyergeier can you check the WM_CLASS of your main Thunderbird window with the xprop command?

You can just run xprop with no arguments in the terminal and then click on the Thunderbird window in order to "target" it for the xprop command. For your convenience you can also filter the output directly:

xprop | grep "WM_CLASS"

My Output (after clicking the Thunderbird window):
WM_CLASS(STRING) = "Mail", "thunderbird-esr"

Further details on my setup:

Pop!_OS 22.04 LTS GNOME version 42.9 Window System: X11 Thunderbird 128.1.0esr (64-bit)

lamyergeier commented 1 month ago

I use wayland, may be thats why xprop shows no output.

Fedora 40 Gnome 46 Wayland Thunderbird 128.1.0esr (64-bit)

philg-dev commented 1 month ago

I'm not extremely well versed in the Linux world yet. But you might try alternatives to xprop that work with Wayland. I've found these potential alternatives in a Reddit post:

- Hyprprop
- Hyprctl
- Wlprop
- Sway-prop

From what I can tell, the closest fit should probably be Wlprop... You'll have to look into it yourself though.

lamyergeier commented 1 month ago

It is thunderbird-esr

philg-dev commented 1 month ago

So you might wanna try to add StartupWMClass=thunderbird-esr to your Thunderbird.desktop instead of using Mail. Did you already try that?

lamyergeier commented 1 month ago

@philg-dev Thank you. This worked for me!

StartupWMClass=thunderbird-esr
philg-dev commented 1 month ago

Also as a heads up, you might want to remove your e-mail-address from your post. If you didn't notice, it's visible in your screenshot

philg-dev commented 1 month ago

Awesome! I've just tested StartupWMClass=thunderbird-esr on my X11 setup as well and it also works for me.

That way we found a solution that works for both Wayland and X11 in the same way!

Great teamwork :-) I'll file a pull request for it shortly.