4

I have used the answers given here How to create a desktop shortcut in Unity? to set a custom application shortcut for spacemacs. While the shortcut works for launching the application, on running, the Emacs icon pops up and is used for selecting the program etc. This is unlike ordinary applications such as Evince where the running icon and launch icon are the same.

Example_image

Is it possible to get the custom icon to behave in an identical manner as Evince and other ordinary program icons? I am using Ubuntu 15.10.

Contents of spacemacs.desktop file:

[Desktop Entry]
Name=Spacemacs
GenericName=Text Editor
Comment=Edit text
MimeType=text/english;text/plain;text/x-makefile;text/x-c++hdr;text/xc++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascaltext/x-tcl;text/x-tex;application/x-shellscript;text/x-c;text/x-c++;
Exec=emacs %F
Icon=/home/varunubuntu/.emacs.d/core/banners/img/spacemacs.png
Type=Application
Terminal=false
Categories=Development;TextEditor;
StartupWMClass=Emacs

EDIT: For clarifying after a few comments: the ideal behaviour for me would be that the Emacs icon should not pop up and the Spacemacs icon (put in by hand) should behave identically as the Evince icon.

typesanitizer
  • 197
  • 1
  • 13

2 Answers2

2

The line StartupWMClass=Emacs is incorrect. It should be:

StartupWMClass=emacs24

or

StartupWMClass=Emacs24

You can find out by opening a terminal window, type

xprop WM_CLASS

then click on the window of your application

Jacob Vlijm
  • 83,767
  • That doesn't fix the issue; the behaviour is identical to the earlier one. See the comments on the question. The output is WM_CLASS(STRING) = "emacs", "Emacs24". – typesanitizer Jan 27 '16 at 17:42
  • @varun That is quite impossible, did you edit the line? – Jacob Vlijm Jan 27 '16 at 17:43
  • 2
    When in doubt, log out and back in. Also, where is the desktop file located? /usr/share/applications/ or ~/.local/share/applications/? Is one in both locations maybe? – Byte Commander Jan 27 '16 at 17:46
  • I have tried different variants of emacs24, Emacs24 and Emacs and the output is the same. Am I correct in understanding that I only need to restart the application or do I need to logout and login again? The file is located in /usr/share/applications. – typesanitizer Jan 27 '16 at 17:47
  • @varun It depends; where is the launcher located, and do you have a copy locally and did you lock Emacs to the launcher as well? – Jacob Vlijm Jan 27 '16 at 17:49
  • 2
    Yes, it is working now after logging out and logging in with Emacs24. Many thanks! – typesanitizer Jan 27 '16 at 17:54
  • 1
    @varun always glad it works. Sometimes the Unity launcher can be a bit stubborn. A log out/in can be refreshing then :) – Jacob Vlijm Jan 27 '16 at 17:55
0

A note for future googlers: To get this working in Gnome 3 I also had to delete the file /usr/share/applications/Emacs24.desktop which used the same WM_CLASS. If I didn't, the one in /usr/share seemed to take precedence over my new desktop file in ~/.local/share/applications/Spacemacs.desktop.