1

After installing 16.04 the Emacs icon in the Launcher turned into a question mark:

enter image description here

In 15.10, the icon looked more like this:

enter image description here

I guess the problem might be that I installed Emacs from source ( and not using sudo apt-get install emacs24 ). The binaray is now installed in /opt/emacs-24.5/bin/emacs.

I found this tutorial UnityLaunchersAndDesktopFiles for how to create .desktop files.

If I run find /opt/emacs-24.5/ -name '*.desktop' I get

/opt/emacs-24.5/share/emacs/24.5/etc/emacs.desktop
/opt/emacs-24.5/share/applications/emacs.desktop

and running find /opt/emacs-24.5/share/icons -name '*.png' gives

/opt/emacs-24.5/share/icons/hicolor/48x48/apps/emacs.png
/opt/emacs-24.5/share/icons/hicolor/32x32/apps/emacs.png
/opt/emacs-24.5/share/icons/hicolor/24x24/apps/emacs.png
/opt/emacs-24.5/share/icons/hicolor/128x128/apps/emacs.png
/opt/emacs-24.5/share/icons/hicolor/16x16/apps/emacs.png

How should I proceed now, to create a working .desktop file?

Update:

I have now tried the following:

  • Copied the supplied desktop file that came with emacs to a local folder:

      cp /opt/emacs-24.5/share/applications/emacs.desktop ~/.local/share/applications/emacs.desktop
    
  • Then changed the icon file name of that file:

    [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=/opt/emacs-24.5/share/icons/hicolor/48x48/apps/emacs.png
    Type=Application
    Terminal=false
    Categories=Development;TextEditor;
    StartupWMClass=Emacs
    Keywords=Text;Editor;
    
  • Run desktop-file-validate:

     $ desktop-file-validate ~/.local/share/applications/emacs.desktop 
     /home/hakon/.local/share/applications/emacs.desktop: hint: value item "TextEditor" in key "Categories" in group "Desktop Entry" can be extended with another category among the following categories: Utility
    
  • Run desktop-file-install:

     sudo desktop-file-install --dir=/usr/share/applications/ ~/.local/share/applications/emacs.desktop
    

Still the icon did not change. What am I missing?

2 Answers 2

1

There are two options:

  1. The /opt directory is not in $PATH, which makes the .desktop file invalid, unless you added the directory manually. Usually applications in /opt have an absolute path in their Exec= line. Change it to the absolute path to the executable.
  2. There might be another .desktop file in ~/.local/share/applications, taking the place of your custom .desktop file. Either:

    • drag your home-made .desktop file on to the launcher and see if it works (with correct icon).
    • If not, or alternatively, run the command:

      grep -rl emacs ~/.local/share/applications
      

    to find possible outdated or incorrect .desktop files, launching emacs

1
  • Actually I have added /opt/emacs-24.5/bin to $PATH in my ~/.bashrc so I still think it is strange that it required the absolute path Apr 26, 2016 at 11:46
1

Seems like the problem was not using an absolute path name for the Exec key. Here is a modified /usr/share/applications/emacs.desktop file:

[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=/opt/emacs-24.5/bin/emacs %F
Icon=/opt/emacs-24.5/share/icons/hicolor/scalable/apps/emacs.svg
Type=Application
Terminal=false
Categories=Development;TextEditor;
StartupWMClass=Emacs
Keywords=Text;Editor;
X-Desktop-File-Install-Version=0.22

This seems to work fine now.

1
  • Ah, crap, just posted my answer while yours popped up... So the first option it was :) Apr 26, 2016 at 11:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .