89luca89 / 89luca89/distrobox

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

Aberta Para iniciantes
#1,808 11 comentários 1 reação 0 responsáveis Ver no GitHub
bug
Linguagem predominante
Go
Estrelas
13k
Forks
541
Merge médio
20h 47min
PRs com merge (30d)
4

Descrição

**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 `-.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*
```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*
```sh
#!/bin/sh

fix_icon() {
if [ $# -lt 2 ]; then
echo "Usage: fix_icon [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"
```

Guia de contribuição

Abrir o guia de contribuição

Direção de pesquisa

Analise o script `distrobox generate-entry` para entender como os arquivos de desktop são criados. O problema é que o nome do arquivo gerado inclui o prefixo do nome do container, o que prejudica a integração com o desktop. A correção provavelmente envolve modificar a lógica de nomenclatura nesse script. Teste criando um container, exportando um aplicativo e verificando o arquivo de desktop gerado em ~/.local/share/applications/. Verifique a correção garantindo que o arquivo renomeado corresponda à WMClass da janela e que o aplicativo se integre corretamente à barra de tarefas.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
bash, linux, shell
Domínio
cli, desktop
Tipo de issue
Bug
Dificuldade
2/5
Tempo estimado
1-3 horas
Status de atividade
Pouca atividade
Clareza
Claramente especificada
Facilidade para iniciantes
65/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.