3

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.

  • 1
    Please add the content of your .desktop file to your question. – Byte Commander Jan 27 '16 at 17:29
  • My bad. I've put it up now. – cutculus Jan 27 '16 at 17:33
  • Aha. I think it's the line StartupWMClass=Emacs. Remove it and try starting Spacemacs again. Maybe you need to log out and back in for the changes to take effect, but usually not. It should not run as Emacs in the launcher then any more, does it? – Byte Commander Jan 27 '16 at 17:34
  • Yes, on removing that line, there is no active icon in the launcher. However, using Alt-Tab still shows the Emacs icon as earlier. – cutculus Jan 27 '16 at 17:37
  • Can you please open the Spacemacs window, then run xprop WM_CLASS in a terminal and click the Spacemacs window and post the terminal output line? – Byte Commander Jan 27 '16 at 17:38
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

  • 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". – cutculus 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
  • 2
    Yes, it is working now after logging out and logging in with Emacs24. Many thanks! – cutculus 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.

  • 1
    You can suggest an edit to that post. – muru Mar 9 '17 at 7:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.