xiaoyifang / goldendict-ng

The Next Generation GoldenDict
https://xiaoyifang.github.io/goldendict-ng/
Other
1.64k stars 90 forks source link

Add StartupWMClass to the application's ".desktop" file #1467

Closed RomanShumikhin closed 6 months ago

RomanShumikhin commented 6 months ago

Is your feature request related to a problem? Please describe. I am using a flatpak version of the application, it comes with a .desktop file. When you pin the app to KDE's Icons-Only Task Manager and launch it, a new icon is created next to the app's icon. I.e. KDE doesn't recognize that the pinned launcher icon and the running app is the same app. image

Describe the solution you'd like To fix that in Wayland I had to do this:

  1. Run qdbus org.kde.KWin /KWin queryWindowInfo
  2. Copy the value from resourceName: goldendict
  3. Append it to the .desktop file like this:
    ...
    X-Flatpak=io.github.xiaoyifang.goldendict_ng
    StartupWMClass=goldendict <---- HERE

    It would be super helpful if the app came with the .desktop file containing this out-of-the-box.

Describe alternatives you've considered I don't know any alternatives

Additional context Operating System: Arch Linux KDE Plasma Version: 6.0.3 KDE Frameworks Version: 6.0.0 Qt Version: 6.6.3 Graphics Platform: Wayland

shenlebantongying commented 6 months ago

I don't see a problem with this.

Do you mind sending a PR for this change?

The .desktop file is here https://github.com/xiaoyifang/goldendict-ng/blob/staged/redist/io.github.xiaoyifang.goldendict_ng.desktop

RomanShumikhin commented 6 months ago

Hi @shenlebantongying , thank you very much for your swift response! I was about to create a PR for the change then I realized this file is a bit different from the flatpak version of the app I have from here https://flathub.org/apps/io.github.xiaoyifang.goldendict_ng I cannot confirm that this change will work for a non-flatpak version of the app. Here is the desktop file from the flatpak version for comparison with the file you mentioned:

[Desktop Entry]
Type=Application
Terminal=false
Categories=Office;Dictionary;Education;Qt;
Name=GoldenDict-ng
GenericName=Multiformat Dictionary
GenericName[zh_CN]=多格式字典
Comment=A feature-rich dictionary lookup program
Comment[zh_CN]=多功能字典查询软件
Keywords=dict;dictioanry;
Keywords[zh_CN]=dict;dictioanry;字典;
Icon=io.github.xiaoyifang.goldendict_ng
Exec=/usr/bin/flatpak run --branch=stable --arch=x86_64 --command=goldendict --file-forwarding io.github.xiaoyifang.goldendict_ng @@u %u @@
MimeType=x-scheme-handler/goldendict;x-scheme-handler/dict;
X-Desktop-File-Install-Version=0.27
X-Flatpak=io.github.xiaoyifang.goldendict_ng

The exec command is different and it might affect the suggested fix. I cannot guarantee that the change I am suggesting here will work.... Would you like me to create a PR anyways?

shenlebantongying commented 6 months ago

The exec command is different and it might affect the suggested fix. I cannot guarantee that the change I am suggesting here will work....

The X-Flatpak/X-Desktop-File-Install-Version/Exec are modified/added by Flatpak. We don't need to care about them.

I tested the native version, the resourceName is also goldendict.

Just add StartupWMClass line should work.

This appears to be able to fix https://github.com/xiaoyifang/goldendict-ng/issues/1160

RomanShumikhin commented 6 months ago

Alright, I created a PR here, thanks again for your swift response and verifying the fix, @shenlebantongying !