Launching your application¶
Most applications on Linux can be launched from the command line, even if they
don’t show output in the terminal. To allow this, you need an executable file in any
of the directories listed in the
PATH environment variable.
These will often end in
bin, such as
On Unix, an executable file is one with the ‘execute bit’ set in its permissions. You can make a file executable with this command:
chmod +x path/to/file
The file should be either a compiled ‘binary’, or a text script. Scripts need to start with a ‘shebang’, a line that identifies the interpreter to run the script with. For example:
The command is the filename. By convention, it should be lower case. If you
want to use more than one word, separate them with hyphens, e.g.
To add your application to the desktop launcher or applications menu, you need
a desktop entry file, with a
.desktop extension. It contains something like
[Desktop Entry] Version=1.0 Type=Application # The name will be displayed Name=Inkscape # Translations are possible: they're used depending on the system locale Name[hi]=इंकस्केप # See the icon section for how this is looked up. Icon=inkscape # The command to launch your application. %F is for file paths to open. Exec=inkscape %F # File types it can open; see file associations. MimeType=image/svg+xml;...
Your application’s desktop entry is also used for file association.
There are a number of other optional fields you can use. See the links below for more information.
These desktop files are placed in an
applications subdirectory of each
XDG data directory.
If you have to put it in place yourself, the normal locations
To use your application for opening files from the file manager, specify the
details in your desktop file. In the
Exec field, make
sure your launch command includes a placeholder like
%F may be replaced by one or more file paths. Use lowercase
%f if it can
only handle one path per command.
%u are similar, but they pass
URLs. Local files have URLs starting
file://, but the platform might also
pass HTTP or FTP URLs to your application.
Then use the
MimeType field to specify what MIME types it handles:
There may be other applications that support the same MIME type.
It’s normally up to the user to pick the default application for a file type,
but if you have a good reason to change it, you can use a
file as described in the MIME associations specification.
If the file format you want to open isn’t already defined on the system, you’ll need to define a new MIME type for it.
Define a MIME type¶
A MIME type is meant to be a unique name for a file format, like
text/x-makefile. For new MIME types, the recommended format is
application/vnd.org_name.app_name, filling in the
organisation name and app or format name as appropriate (e.g. Libreoffice ODT
application/vnd.oasis.opendocument.text). You can add
+xml to the end if your file format is based on one of these generic
MIME types are added to the system with XML files like this:
<?xml version="1.0" encoding="UTF-8"?> <mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info"> <mime-type type="application/vnd.acme.frobulate"> <comment>Frobulate file</comment> <glob pattern="*.frobulate"/> </mime-type> </mime-info>
<glob> tag specifies a file extension for files with this MIME type.
Other fields can distinguish different file types sharing the same extension,
but it’s best to pick a unique extension. There’s no need to limit the extension
to three letters.
The filename of this XML file should start with the vendor name, e.g.
xdg-mime install acme-frobulate.xml to install
it. This will copy it into a directory such as
and rebuild the MIME database from all of these XML source files.