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 Coreavor
.
All of this is achieved with the help of a desktop file which is a simple text file with .desktop
extension.
[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.
-
Exec
takes in the instruction to be executed. The%U
at the end takes in command line arguments which are passed to your program. -
TryExec
is the file path to the executable. -
MimeType
is 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.
References:
Top comments (0)