How to fix the Slack icon in Debian - XFCE?
For a while I've been really annoyed that some applications (Slack, React-Native Debugger and some others installed via .deb) appear without an icon in the XFCE task list panel.
It seems to be a bug in the app itself or maybe Electron apps on Debian, and it even happens when installed with SnapStore. Either way, it annoys me.
I spent a lot of time researching and learned that the Window Buttons item gets its configuration from programs’ .desktop files. Searching for Slack's file gives:
$ sudo find / -iname "*slack*.desktop"# Output/home/veuge/.config/autostart/slack.desktop/usr/share/applications/slack.desktop
The file in $HOME/.config/autostart is a symlink to /usr/share/applications, so fixing that one is enough. Its content is:
$ cat /usr/share/applications/slack.desktop# Output[Desktop Entry]Name=SlackStartupWMClass=SlackComment=Slack DesktopGenericName=Slack Client for LinuxExec=/usr/bin/slack %UIcon=/usr/share/pixmaps/slack.pngType=ApplicationStartupNotify=trueCategories=GNOME;GTK;Network;InstantMessaging;MimeType=x-scheme-handler/slack;
The interesting line is Icon=/usr/share/pixmaps/slack.png; the image exists and has correct permissions.
$ ls -l /usr/share/pixmaps/slack.png# Output-rw-rw-r-- 1 root root 38884 Mar 15 20:12 /usr/share/pixmaps/slack.png
Since config looks good, it seems like an ElectronJS bug, so there must be another fix. I found this Reddit discussion; the second comment says the workaround is to reset the icon after Slack opens, with two steps:
- Get Slack window ID using
xwininfo. - Set the window icon using
xseticon.
Manual process:
$ xwininfo -root -tree | sed -e 's/^ *//'| grep -E '0x.*Slack\s{1}\|' | awk '{print $1}'# Output0x4400005$ xseticon -id 0x4400005 /usr/share/pixmaps/slack.png
After running xtseticon the result is:
As Reddit says, doing this manually every Slack launch is suboptimal, so we tweak Exec in /usr/share/applications/slack.desktop to update icon automatically once Slack is known started.
I replicated the approach from this comment in a script, and then call that script from slack.desktop.
Script breakdown:
# Permite sobreescribir el .desktopenv BAMF_DESKTOP_FILE_HINT=$SLACK_DESKTOP# Comando que abre Slack minimizado y sin output/usr/bin/slack -u %U & > /dev/null# Pausa para esperar que Slack iniciesleep 10# Obtiene window ID de Slack y lo guarda en la variable app_widapp_wid=$(xwininfo -root -tree |sed -e 's/^ *//'|grep -E '0x.*Slack\s{1}\|' | awk '{print $1}')# Actualiza el ícono dado el window ID y el icono en png.xseticon -id $app_wid $SLACK_ICON
And finally, the modified slack.desktop:
[Desktop Entry]Name=SlackStartupWMClass=SlackComment=Slack DesktopGenericName=Slack Client for LinuxExec=sh -c /home/veuge/slack-init.shIcon=/usr/share/pixmaps/slack.pngType=ApplicationStartupNotify=trueCategories=GNOME;GTK;Network;InstantMessaging;MimeType=x-scheme-handler/slack;
Conclusion
- This is a workaround to restore Slack/other app icons in XFCE; the real cause should be diagnosed.
- It works when Slack is started manually or via auto-start.
- The script can be improved to make it configurable and reusable for other applications with this icon bug. (I'll do that someday).