Table of Contents
The freedesktop.org Desktop Entry specification allows applications to announce which intents they support, using the Implements key.
An intent can be represent the fact that the application provides a certain type of functionality (e.g. "a calculator"), implements a specific DBus interface (e.g. org.freedesktop.FileManager1), or anything else that is agreed among all applications implementing the intent.
This specification solves the issue of which application should be used for a given intent by default, how to let the user change the default application.
Users, system administrators, application vendors and distributions can change associations between applications and intents by writing into a file called intentapps.list.
The lookup order for this file is as follows:
$XDG_CONFIG_HOME/$desktop-intentapps.list | user overrides, desktop-specific (for advanced users) |
$XDG_CONFIG_HOME/intentapps.list | user overrides (recommended location for user configuration GUIs) |
$XDG_CONFIG_DIRS/$desktop-intentapps.list | sysadmin and ISV overrides, desktop-specific |
$XDG_CONFIG_DIRS/intentapps.list | sysadmin and ISV overrides |
$XDG_DATA_DIRS/applications/$desktop-intentapps.list | distribution-provided defaults, desktop-specific |
$XDG_DATA_DIRS/applications/intentapps.list | distribution-provided defaults |
In this table, $desktop is one of the names of the current desktop, lowercase (for instance, kde, gnome, xfce, etc.)
This is determined from taking the ascii-lowercase form of a component the environment variable $XDG_CURRENT_DESKTOP, which is a colon-separated list of names that the current desktop is known as.
The $desktop variable should be each of these values in turn.
All of the above files are referred to as "intentapps.list" in the rest of this specification, for simplicity.
Note that, despite the similarity to the mimeapps.lst spec, it is not possible to add or remove associations from any of these files.
Indicating the default application for a given intent is done by writing into the group [Default Applications] in the file intentapps.list.
The [Default Applications] group indicates the default application to be used for a given intent. If the application is no longer installed, the next application in the list is attempted, and so on.
This example ensures that the application default1.desktop will be used for intent1, if it's installed and associated with the intent, and otherwise default2.desktop if it's installed and associated:
[Default Applications] intent1=default1.desktop;default2.desktop;
The value is a semicolon-separated list of desktop file IDs (as defined in the desktop entry spec).
In the absence of such an entry, the next intentapps.list is checked. Once all levels have been checked, if no entry could be found, the implementation should pick the most-preferred .desktop files associated with the intent.
The suggested algorithm for determining the default application for a given intent is:
get the list of desktop ids for the given intent under the "Default Applications" group in the first intentapps.list
for each desktop ID in the list, attempt to load the named desktop file, using the normal rules
if a valid desktop file is found, verify that it is associated with the intent
if a valid association is found, we have found the default application
if after all list items are handled, we have not yet found a default application, proceed to the next intentapps.list file in the search order and repeat
if after all files are handled, we have not yet found a default application, we are free to choose how to pick one among the available implementations of the intent. This might include hardcoding a preferred default (e.g. from the same desktop environment / software stack), sorting available desktop files by desktop ID to pick the first, actually asking the user about their preference... In any case it should be consistent across runs rather than random (e.g. based on the order of an unsorted list of files from a directory).
Note that a desktop ID set as the default for an application can refer to a desktop file of the same name found in a directory of higher precedence.
Note as well that the default application for a given intent must be an application that is associated with the intent. It is not possible to arbitrarily associate applications with new intents.
It's also possible to put several implementations of an intent in order of preference by reading all intentapps.list files in the order above. Remember however that these files cannot be used to find all implementations of an intent; the desktop files are the canonical source of that information.