89luca89/distrobox

[Error] Running applications do not match the exported desktop file

ReK42 opened this issue · 1 comments

Describe the bug
Some applications do not correctly associate with the *.desktop file while running, using a generic icon and separating themselves from the pinned icon in the taskbar.

There have been several issues regarding this in the past (#1306, #128) which have been closed, however the issue persists. In addition, the previous issues are regarding GNOME but I am experiencing the same behaviour on KDE as well.

To match correctly, two things must both be correct:

  1. The StartupWMClass entry in the desktop file must match the window's WMClass.
  2. The name of the desktop file on the host must match the name of the file on the container.

Currently, distrobox generate-entry creates the desktop file with the name <container_name>-<application_name>.desktop (e.g.: fedora-sublime_text.desktop). This breaks the second requirement.

To Reproduce
Use distrobox assemble with the boxes.ini file below on a Wayland system. When starting any of the three applications you will observe this behaviour. Close the applications and run the fix-icons.sh script below to resolve all three.

Note that Proton Mail also has an incorrect StartupWMClass which the script fixes, but that is a separate issue.

Expected behavior
No additional scripting or manual fixes are required to get properly functioning application integration.

Logs
N/A

Desktop (please complete the following information):

  • Distrobox Version: 1.8.1.2
  • Podman Version: 5.5.2
  • Operating System: Bazzite 42
  • KDE Plasma Version: 6.4.3
  • KDE Frameworks Version: 6.16.0
  • Qt Version: 6.9.1
  • Kernel Version: 6.15.6-113.bazzite.fc42.x86_64 (64-bit)
  • Graphics Platform: Wayland

Additional context
Useful tip: The following command can display the window's class on KDE:

user@host:~$ qdbus org.kde.KWin /KWin queryWindowInfo
[...]
desktopFile: sublime_text
resourceClass: sublime_text
resourceName: 
role: 
[...]

Files
boxes.ini

[fedora]
image=fedora:latest
nvidia=true
pull=true
replace=true
start_now=true
additional_packages=fastfetch

# Sublime Text & Sublime Merge
pre_init_hooks=rpm -v --import https://download.sublimetext.com/sublimehq-rpm-pub.gpg
pre_init_hooks=dnf config-manager addrepo --from-repofile=https://download.sublimetext.com/rpm/stable/x86_64/sublime-text.repo
additional_packages=sublime-text sublime-merge
exported_apps=sublime_text sublime_merge


# Proton Mail Desktop
additional_packages=https://proton.me/download/mail/linux/ProtonMail-desktop-beta.rpm
exported_apps=proton-mail

fix-icons.sh

#!/bin/sh

fix_icon() {
    if [ $# -lt 2 ]; then
        echo "Usage: fix_icon <container_name> <application_name> [window_class]"
        exit 1
    fi

    # Clean up any old versions
    if [ -f $HOME/.local/share/applications/$2.desktop ]; then
        rm $HOME/.local/share/applications/$2.desktop
    fi

    # Rename the application file
    mv $HOME/.local/share/applications/$1-$2.desktop $HOME/.local/share/applications/$2.desktop

    # Replace the StartupWMClass if required
    if [ $# -gt 2 ]; then
        sed -i "s/StartupWMClass=.*/StartupWMClass=$3/" $HOME/.local/share/applications/$2.desktop
    fi
}

fix_icon fedora sublime_text
fix_icon fedora sublime_merge
fix_icon fedora proton-mail "Proton Mail"

I've experienced the same issue on Bazzite 42 with KDE 6.4.4.

I ran into it while testing my application, it took me some time to realise it was caused by distrobox rather than my own app.