You just made an awesome app! Now you want others to be able to install it, and use it. You may want it to appear on the main menu, it must be searchable, it must appear in the context menu as "open with ". You might further want to pin it to the dock or add it to favorites.
Taking the example of Coreavor, a simple image viewer that I made recently, I needed to associate the program with images so that I can right click and open it in
All of this is achieved with the help of a desktop file which is a simple text file with
[Desktop Entry] Type=Application Name=Coreavor Icon=/usr/share/icons/coreavor.png Comment=A simple Image Viewer Exec=/usr/local/bin/Coreavor %U TryExec=/usr/local/bin/Coreavor Terminal=false MimeType=image/png;image/gif;image/jpg;
Every desktop file must have this structure, although not all fields are compulsory, but messing up a field might result in unwanted results.
Most of these fields are self explanatory.
Exectakes in the instruction to be executed. The
%Uat the end takes in command line arguments which are passed to your program.
TryExecis the file path to the executable.
MimeTypeis used to associate your program with files of a certain type.
You can read about the standard and information regarding more keys used in
.desktop file here
Place this file in the
/usr/share/applications directory so that it is accessible system wide, or in
~/.local/share/applications to only make it accessible to a particular user.
All your other apps' desktop files are present here. You can have a look at any of these files to understand and learn from them.