Creating a Linux desktop launcher/menu entry

Linux users often like to install additional software manually, for example software that is not in one of the official software repositories. What this software often lacks is the appropriate launcher for the graphical interface.

For it to appear, a so-called .desktop file has to be created. The file specification was standardized by the Free Desktop Group and can therefore be used across distributions.

As an example, here is the .desktop file I created for my manually installed CMapsTools.

[Desktop Entry] 
Type=Application 
Name=CMap Tools Comment=Concept Maps 
Exec="/home/cmuench/opt/IHMC CmapTools/bin/CmapTools" 
Icon=/home/cmuench/opt/IHMC CmapTools/cmaptools.png 
Categories=Office; 
Terminal=false 
StartupWMClass=com-zerog-lax-LAX

The file can be placed under /usr/local/share/applications if it should apply to all users of the system. Since I use the system on my own and like to install everything so that I retain control over everything in my home directory, I placed the file under ~/.local/share/applications.

An important realization for me was that the path under Exec must always be enclosed in quotation marks if it contains spaces. The path for the icon should not be enclosed in quotation marks.

The correctness of the file can be checked with the "desktop-file-validate" command. The validator can be installed through the desktop-file-utils package on Debian/Ubuntu or Redhat/Fedora.

The desktop files should be reloaded automatically after a while. If you use Gnome, you can speed up the process as follows: Alt + F2 r.

Important! This only works if all paths in the file are specified correctly. If your entry does not appear in the menu, most errors come down to incorrect paths.

Have fun!