Pinned emacs is not grouped on task manager

Hello,

I have few apps pinned to my task manager and one of them - emacs - is causing me problems when I start it for the first time after turning on the computer. Instead of being grouped into one icon, when I start it for the first time, it is shown in two separate icons like this:

kde_double_icons

In order to fix it I need to unpin the first icon, pin the second one and then I have only one icon - that is until I restart my computer and again have double emacs icons.

Any ideas how to force emacs to stay in the one pinned icon on my task manager? Thank you.

I’m using:

  • Manjaro KDE

My first thought is that this is a side effect of there being two different emacs programs within the emacs package. However, I am unable to reproduce this on my machine, so there must be some other factor involved. In fact, both versions are considered to be the same by my taskbar.

When I enter “emacs” in start menu I also get two positions:
image

I found their desktop files (but most of the time I start emacs by shortcut super + 2 because it’s the second pinned icon). The emacs.desktop is:

[Desktop Entry]
Name=Emacs
GenericName=Text Editor
Comment=Edit text
MimeType=text/english;text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-c;text/x-c++;
Exec=emacs %F
Icon=emacs
Type=Application
Terminal=false
Categories=Development;TextEditor;
StartupNotify=true
StartupWMClass=Emacs

and the emacsclient.desktop is:

[Desktop Entry]
Name=Emacs (Client)
GenericName=Text Editor
Comment=Edit text
MimeType=text/english;text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-c;text/x-c++;
Exec=sh -c "if [ -n \\"\\$*\\" ]; then exec emacsclient --alternate-editor= --display=\\"\\$DISPLAY\\" \\"\\$@\\"; else exec emacsclient --alternate-editor= --create-frame; fi" placeholder %F
Icon=emacs
Type=Application
Terminal=false
Categories=Development;TextEditor;
StartupNotify=true
StartupWMClass=Emacs
Keywords=emacsclient;
Actions=new-window;new-instance;

[Desktop Action new-window]
Name=New Window
Exec=/usr/bin/emacsclient --alternate-editor= --create-frame %F

[Desktop Action new-instance]
Name=New Instance
Exec=emacs %F

Also the error doesn’t happen all the time instantly when I start emacs. Sometimes it happens few hours after starting emacs and I think sometimes there are some lucky days where it stays whole day (or most of it) where it should :). Maybe it’s plasma bug? Or maybe emacs server executable switches by itself to emacsclient executable and plasma thinks it’s different program…

Not sure if it’s connected but I also noticed (but this one is rare) strange behavior with discord app, that is pinned too (but on different KDE activity). Sometimes discord icon (without starting discord at all) replaces slack icon in my current KDE activity (even though it’s not pinned in this activity at all). But then it’s enough for me to switch to my second activity (where discord is pinned) and go back to the first one and slack icon is again properly displayed (instead of discord).

If anybody has any ideas what could be worth checking let me know. Thank you.

Is it possible to pin/unpin apps to task manager using only CLI?

I don’t believe so.