Difference between revisions of "XDG MIME Applications"

From ArchWiki
Jump to: navigation, search
m (Corrected MimeTypes to MimeType)
m (mimeapps.list: fix broken link)
 
(380 intermediate revisions by 34 users not shown)
Line 1: Line 1:
[[Category:Desktop environments]]
+
[[Category:Freedesktop.org]]
[[zh-cn:Default Applications]]
+
[[ja:デフォルトアプリケーション]]
{{Poor writing|need better introduction (second point is not described)}}
+
[[ru:Default applications]]
There are numerous places to configure default applications on Linux. This page will attempt to address problems related to the following issues:
+
[[zh-hans:Default applications]]
* You need to change a certain default application (e.g. after switching desktop environments), but there appears to be nowhere to configure it, or an application ignores your configuration
+
{{Related articles start}}
* You regularly switch back and forth between several desktop environments, and need to configure some applications (e.g. file manager) on a per-desktop-environment basis, but need to configure others (e.g. web browser) globally
+
{{Related|Desktop entries}}
 +
{{Related|Desktop environment}}
 +
{{Related|Window manager}}
 +
{{Related articles end}}
 +
The [https://specifications.freedesktop.org/mime-apps-spec/mime-apps-spec-latest.html XDG MIME Applications specification] builds upon the [[#Shared MIME database]] and [[#Desktop entries]] to provide [[default applications]].
  
== Changing a default application ==
+
== Shared MIME database ==
=== xdg-open ===
 
[[xdg-open]] is a desktop-independent tool for configuring default applications.
 
  
==== Exactly how it works ====
+
The [https://specifications.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-latest.html XDG Shared MIME-info Database specification] facilitates a shared MIME database across desktop environments and allows applications to easily register new MIME types system-wide.
{{Accuracy|[[xdg-open]] and many other applications now use {{ic|~/.local/share/applications/mimeapps.list}} instead of {{ic|~/.local/share/applications/defaults.list}}}}
 
This is currently very shaky because the standard in question ([http://www.freedesktop.org/wiki/Specifications/mime-actions-spec relevant freedesktop.org document], "Default application ordering" section) is still not finalised and it is even less correctly implemented.
 
  
What happens with the current version of xdg-open (extra/xdg-utils 1.1.0rc1-3) is the following: xdg-open uses xdg-mime (among other things; if you use a mainstream DE like GNOME, KDE or LXDE, xdg-open might try using their specific tools before xdg-mime) to find the MIME type of the file that is to be opened and the default application associated with that MIME type. xdg-mime looks for the default application in the following files:
+
The database is built from the XML files installed by packages in {{ic|/usr/share/mime/packages/}} using the tools from {{Pkg|shared-mime-info}}.
  
/usr/share/applications/defaults.list      (global)
+
The files in {{ic|/usr/share/mime/}} should not be directly edited, however it is possible to maintain a separate database on a per-user basis in the {{ic|~/.local/share/mime/}} tree.
~/.local/share/applications/defaults.list  (per user, overrides global)
 
  
The syntax of these files is:
+
"URI scheme handling [..] are handled through applications handling the {{ic|x-scheme-handler/foo mime-type}}, where foo is the URI scheme in question."[https://specifications.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-latest.html#idm140625828587776]
  
[Default Applications]
+
=== New MIME types ===
mimetype=desktopfile1;desktopfile2;...;desktopfileN
 
  
E.g.
+
{{expansion|Is the process different for assigning an extension to an existing MIME type?}}
  
[Default Applications]
+
This example defines a new MIME type {{ic|application/x-foobar}} and assigns it to any file with a name ending in ''.foo''. Simply create the following file:
text/html=firefox.desktop;chromium.desktop
 
  
The intent is to be able to specify applications in order of preference so the next would be selected if the previous is unavailable. However, xdg-open is currently '''broken''' and specifying more than one application for a single MIME type will result in none being used. Be sure to specify only '''one''' application per MIME type.
+
{{hc|~/.local/share/mime/packages/application-x-foobar.xml|2=
 +
<?xml version="1.0" encoding="UTF-8"?>
 +
<nowiki><mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info"></nowiki>
 +
    '''<mime-type type="application/x-foobar">'''
 +
        <comment>foo file</comment>
 +
        <icon name="application-x-foobar"/>
 +
        <glob-deleteall/>
 +
        '''<glob pattern="*.foo"/>'''
 +
    </mime-type>
 +
</mime-info>
 +
}}
 +
 
 +
And then update the MIME database:
 +
 
 +
$ update-mime-database ~/.local/share/mime
 +
 
 +
Of course this will not have any effect if no desktop entries are associated with the MIME type. You may need to create new [[desktop entries]] or modify [[#mimeapps.list]].
 +
 
 +
== Desktop entries ==
 +
 
 +
Each package can use [[desktop entries]] to provide information about the MIME types that can be handled by the packaged software. In order to provide fast search in the reverse direction, the system uses the tools from the {{Pkg|desktop-file-utils}} package to analyze the desktop files and to create an inverse mapping stored in the {{ic|/usr/share/applications/mimeinfo.cache}} file. This is the only file that programs need to read to find all desktop files that might be used to handle given MIME type. Using the database is easier and faster than reading hundreds of ''.desktop'' files directly.
 +
 
 +
The files in {{ic|/usr/share/applications/}} should not be edited directly, it is possible to maintain a separate database on a per-user basis in the {{ic|~/.local/share/applications/}} tree. See [[Desktop entries]] for details.
 +
 
 +
== mimeapps.list ==
 +
 
 +
The [https://specifications.freedesktop.org/mime-apps-spec/mime-apps-spec-1.0.html XDG standard] is the most common for configuring desktop environments. Default applications for each MIME type are stored in {{ic|mimeapps.list}} files, which can be stored in several locations. They are searched in the following order, with earlier associations taking precedence over later ones:
 +
 
 +
{| class="wikitable"
 +
! Path !! Usage
 +
|-
 +
| {{ic|~/.config/mimeapps.list}} || user overrides
 +
|-
 +
| {{ic|/etc/xdg/mimeapps.list}} || system-wide overrides
 +
|-
 +
| {{ic|~/.local/share/applications/mimeapps.list}} || ('''deprecated''') user overrides
 +
|-
 +
| {{ic|/usr/local/share/applications/mimeapps.list}}<br>{{ic|/usr/share/applications/mimeapps.list}} || distribution-provided defaults
 +
|}
 +
 
 +
Additionally, it is possible to define [[desktop environment]]-specific default applications in a file named {{ic|''desktop''-mimeapps.list}} where {{ic|''desktop''}} is the name of the desktop environment (from the {{ic|XDG_CURRENT_DESKTOP}} environment variable). For example, {{ic|/etc/xdg/xfce-mimeapps.list}} defines system-wide default application overrides for [[Xfce]]. These desktop-specific overrides take precedence over the corresponding non-desktop-specific file. For example, {{ic|/etc/xdg/xfce-mimeapps.list}} takes precedence over {{ic|/etc/xdg/mimeapps.list}} but is still overridden by {{ic|~/.config/mimeapps.list}}.
 +
 
 +
{{Tip|1=Although deprecated, several applications still read/write to {{ic|~/.local/share/applications/mimeapps.list}}. To simplify maintenance, simply symlink it {{bc|$ ln -s ~/.config/mimeapps.list ~/.local/share/applications/mimeapps.list}}. Note that the symlink must be in this direction because [[xdg-utils]] deletes and recreates {{ic|~/.config/mimeapps.list}} when it writes to it, which will break any symbolic/hard links}}
 +
 
 +
{{Note|You might also find files in these locations named {{ic|defaults.list}}. This file is similar to {{ic|mimeapps.list}} except it only lists default applications (not added/removed associations). It is now deprecated and should be manually merged with {{ic|mimeapps.list}}.}}
 +
 
 +
==== Format ====
  
Also see [[xdg-open]] for more information on what affects its behaviour. This information is sufficient for a user to configure default applications on Arch currently.
+
Consider the following example:
  
==== How it should work ====
+
{{hc|mimeapps.list|2=
However, the behaviour described in the previous section is actually wrong according to the quoted standard draft. defaults.list should only be used by distributions/DEs to specify sane defaults for that particular environment. This file should only be placed in {{Ic|/usr/share/applications/}}, it should be a system-wide setting and it should not be changed by users. Instead, users should use the files {{ic|/usr/share/applications/mimeapps.list}} (global) and {{ic|~/.local/share/applications/mimeapps.list}} (per user, overrides global) to specify custom file associations. The syntax of these files is as follows:
 
{{hc|mimeapps.list|
 
 
[Added Associations]
 
[Added Associations]
mimetype&#61;desktopfile1;desktopfile2;...;desktopfileN
+
image/jpeg=bar.desktop;baz.desktop
...
+
video/H264=bar.desktop
 
[Removed Associations]
 
[Removed Associations]
mimetype&#61;desktopfile1;desktopfile2;...;desktopfileN
+
video/H264=baz.desktop
}}
+
[Default Applications]
 +
image/jpeg=foo.desktop}}
 +
 
 +
Each section assigns one or more desktop entries to MIME types.
 +
* '''Added Associations''' indicates that the applications support opening that MIME type. For example, {{ic|bar.desktop}} and {{ic|baz.desktop}} can open JPEG images. This might affect the application list you see when right-clicking a file in a file browser.
 +
* '''Removed Associations''' indicates that the applications ''do not'' support that MIME type. For example, {{ic|baz.desktop}} cannot open H.264 video.
 +
* '''Default Applications''' indicates that the applications should be the default choice for opening that MIME type. For example, JPEG images should be opened with {{ic|foo.desktop}}. This implicitly adds an association between the application and the MIME type. If there are multiple applications, they are tried in order.
 +
 
 +
Each section is optional and can be omitted if unneeded.
 +
 
 +
== Utilities ==
 +
 
 +
While it is possible to configure default applications and MIME types by directly editing [[#mimeapps.list]] and the [[#Shared MIME database]], there are many tools that can simplify the process. These tools are also important because applications may delegate opening of files to these tools rather than trying to implement the MIME type standard themselves.
 +
 
 +
If you use a [[desktop environment]] you should first check if it provides its own utility. That should be preferred over these alternatives.
 +
 
 +
The official [[xdg-utils]] contain tools for managing MIME types and default applications according to the XDG standard ([[xdg-utils#xdg-mime|xdg-mime]]). Most importantly it provides [[xdg-open]] which many applications use to open a file with its default application.
 +
 
 +
=== lsdesktopf ===
 +
 
 +
{{AUR|lsdesktopf}} provides several methods of searching the MIME database and desktop MIME entries.
 +
 
 +
For example, to see all MIME extensions in the system's ''.desktop'' files that have MIME type {{ic|video}} you can use {{ic|lsdesktopf --gm -gx video}} or to search in the XML database files use {{ic|lsdesktopf --gdx -gx video}}. To get a quick overview of how many and which ''.desktop'' files can be associated with a certain MIME type, use {{ic|lsdesktopf --gen-mimeapps}}. To see all file name extensions in XML database files, use {{ic|lsdesktopf --gdx -gfx}}.
  
The [Added Associations] section is used to specify preferred (default) applications in decreasing order of preference for the specified MIME type. The [Removed Associations] section is used to explicitly remove any previously inherited associations.
+
== Troubleshooting ==
  
Note that the upstream, yet unreleased xdg-utils were fixed to use mimeapps.list instead of defaults.list but the xdg-open bug (specifying multiple applications breaks it completely) still remains.
+
If a file is not being opened by your desired default application, there are several possible causes. You may need to check each case.
  
Currently, the best option is to use {{AUR|mimeo}}, which implements everything explained above correctly.  There is also {{AUR|xdg-utils-mimeo}} which provides a patched xdg-open to use mimeo. Both are available in [[Arch User Repository|AUR]].
+
=== Missing desktop entry ===
  
=== GNOME 3 ===
+
A [[desktop entry]] is required in order to associate an application with a MIME type. Ensure that such an entry exists and can be used to (manually) open files in the application.
The xdg-open settings are usually recognized by GNOME, but specific configuration is needed for some tasks. See [[GNOME#Miscellaneous settings]] for more details.
 
  
== Custom File Associations ==
+
=== Missing association ===
The following method creates a custom mime type and file association manually.  This is useful if your desktop does not have a mime type/file association editor installed.  In this example, a fictional multimedia application 'foobar' will be associated with all '*.foo' files.  This will be done a per user basis (as opposed to system-wide).
 
  
* First, create the file {{ic|~/.local/share/mime/packages/application-x-foobar.xml}}:
+
If the application's desktop entry does not specify the MIME type under its {{ic|MimeType}} key, it will not be considered when an application is needed to open that type. Edit [[#mimeapps.list]] to add an association between the .desktop file and the MIME type.
  
$ mkdir -p ~/.local/share/mime/packages
+
=== Non-default application ===
$ cd ~/.local/share/mime/packages
 
$ touch application-x-foobar.xml
 
  
* Then edit {{ic|~/.local/share/mime/packages/application-x-foobar.xml}} and add this text:
+
If the desktop entry is associated with the MIME type, it may simply not be set as the default. Edit [[#mimeapps.list]] to set the default association.
<pre>
 
<?xml version="1.0" encoding="UTF-8"?>
 
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
 
<mime-type type="application/x-foobar">
 
<comment>foo file</comment>
 
<icon name="application-x-foobar"/>
 
<glob-deleteall/>
 
<glob pattern="*.foo"/>
 
</mime-type>
 
</mime-info>
 
</pre>
 
Note that you can use any icon, including one for another application.
 
  
* Next, edit or create the file {{ic|~/.local/share/applications/foobar.desktop}} to contain something like:
+
=== Nonstandard association ===
  
[Desktop Entry]
+
Applications are free to ignore or only partially implement the XDG standard. Check for usage of deprecated files such as {{ic|~/.local/share/applications/mimeapps.list}} and {{ic|~/.local/share/applications/defaults.list}}. If you are attempting to open the file from another application (e.g. a web browser or file manager) check if that application has its own method of selecting default applications.
Name=Foobar
 
Exec=/usr/bin/foobar
 
MimeType=application/x-foobar
 
Icon=foobar
 
Terminal=false
 
Type=Application
 
Categories=AudioVideo;Player;Video;
 
Comment=
 
  
Note that Categories should be set appropriately for the application type (in this example, a multimedia app).
+
=== Variables in .desktop files that affect application launch ===
  
* Now update the mime database with:
+
{{Expansion|1=The fact {{ic|MimeType}} entries may be missing in the desktop files is only implied here, i.e. "Even if an application...", though this is a common cause of errors. Some openers may also associate mime types not explicitly listed in a desktop file (such as {{Pkg|exo}}). Further environment-specific factors are at play, e.g. whether {{ic|1=Terminal=true}} has an effect, though latter should arguably be expanded on in [[Desktop entries]].}}
  
$ update-mime-database ~/.local/share/mime
+
Desktop environments and file managers supporting the specifications launch programs according to definition in the ''.desktop'' files. See [[Desktop entries#Application entry]].  
  
Programs that use mime types, such as file managers, should now open '*.foo' files with foobar. (You may need to restart your file manager to see the change.)
+
Usually, configuration of the packaged ''.desktop'' files is not required, but it may not be bug-free. Even if an application containing necessary MIME type description in the ''.desktop'' file {{ic|MimeType}} variable that is used for association, it can fail to start correctly, not start at all or start without opening a file.  
  
== Maintaining settings for multiple desktop environments ==
+
This may happen, for example, if the {{ic|Exec}} variable is missing internal options needed for how to open a file, or how the application is shown in the menu. The {{ic|Exec}} variable usually begins with {{ic|%}}; for its currently supported options, see [https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#exec-variables exec-variables].
The {{ic|OnlyShowIn}} field of a .desktop file may be useful; see [http://standards.freedesktop.org/menu-spec/latest/ this page]. I haven't tried setting this field yet; please update this wiki page if you have any info about using {{ic|OnlyShowIn}}.
 
  
== Troubleshooting ==
+
The following table lists the main variable entries of ''.desktop'' files that affect how an application starts, if it has a MIME type associated with it.  
=== Applications don't appear in the ''Open With...'' context menu (of a file manager) ===
 
Sometimes, a certain application will not appear in the right-click ''Open With...'' dialog. To fix this problem, locate the {{Ic|.desktop}} file in {{Ic|/usr/share/applications}}, edit it as root, and add {{Ic|%U}} to the end of the {{Ic|1=<nowiki>Exec=</nowiki>}} line. For example, Kile currently has this problem; you need to edit {{Ic|/usr/share/applications/kde4/kile.desktop}} and change the line reading {{Ic|1=<nowiki>Exec=kile</nowiki>}} to read {{Ic|1=<nowiki>Exec=kile %U</nowiki>}}. Also, please file a bug against the upstream project if you notice this problem.
 
  
You may also have to edit the {{Ic|MimeType}} list in the {{Ic|.desktop}} file if you install extensions that allow an application to handle additional MIME types.
+
{| class="wikitable"
 +
! Variable names !! Example 1 content !! Example 2 content !! Description
 +
|-
 +
| DBusActivatable || DBusActivatable=true || DBusActivatable=false || Application interact with [https://www.freedesktop.org/wiki/Software/dbus/ D-Bus]. <br> See also configuration: [https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#dbus D-Bus].
 +
|-
 +
| MimeType || MimeType=application/vnd.oasis.opendocument.text || MimeType=application/vnd.sun.xml.math || List of MIME types supported by application
 +
|-
 +
| StartupWMClass || StartupWMClass=google-chrome || StartupWMClass=xpad || Associate windows with the owning application
 +
|-
 +
| Terminal || Terminal=true || Terminal=false || Start in default terminal
 +
|}

Latest revision as of 15:16, 25 April 2018

The XDG MIME Applications specification builds upon the #Shared MIME database and #Desktop entries to provide default applications.

Shared MIME database

The XDG Shared MIME-info Database specification facilitates a shared MIME database across desktop environments and allows applications to easily register new MIME types system-wide.

The database is built from the XML files installed by packages in /usr/share/mime/packages/ using the tools from shared-mime-info.

The files in /usr/share/mime/ should not be directly edited, however it is possible to maintain a separate database on a per-user basis in the ~/.local/share/mime/ tree.

"URI scheme handling [..] are handled through applications handling the x-scheme-handler/foo mime-type, where foo is the URI scheme in question."[1]

New MIME types

Tango-view-fullscreen.pngThis article or section needs expansion.Tango-view-fullscreen.png

Reason: Is the process different for assigning an extension to an existing MIME type? (Discuss in Talk:XDG MIME Applications#)

This example defines a new MIME type application/x-foobar and assigns it to any file with a name ending in .foo. Simply create the following file:

~/.local/share/mime/packages/application-x-foobar.xml
<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
    <mime-type type="application/x-foobar">
        <comment>foo file</comment>
        <icon name="application-x-foobar"/>
        <glob-deleteall/>
        <glob pattern="*.foo"/>
    </mime-type>
</mime-info>

And then update the MIME database:

$ update-mime-database ~/.local/share/mime

Of course this will not have any effect if no desktop entries are associated with the MIME type. You may need to create new desktop entries or modify #mimeapps.list.

Desktop entries

Each package can use desktop entries to provide information about the MIME types that can be handled by the packaged software. In order to provide fast search in the reverse direction, the system uses the tools from the desktop-file-utils package to analyze the desktop files and to create an inverse mapping stored in the /usr/share/applications/mimeinfo.cache file. This is the only file that programs need to read to find all desktop files that might be used to handle given MIME type. Using the database is easier and faster than reading hundreds of .desktop files directly.

The files in /usr/share/applications/ should not be edited directly, it is possible to maintain a separate database on a per-user basis in the ~/.local/share/applications/ tree. See Desktop entries for details.

mimeapps.list

The XDG standard is the most common for configuring desktop environments. Default applications for each MIME type are stored in mimeapps.list files, which can be stored in several locations. They are searched in the following order, with earlier associations taking precedence over later ones:

Path Usage
~/.config/mimeapps.list user overrides
/etc/xdg/mimeapps.list system-wide overrides
~/.local/share/applications/mimeapps.list (deprecated) user overrides
/usr/local/share/applications/mimeapps.list
/usr/share/applications/mimeapps.list
distribution-provided defaults

Additionally, it is possible to define desktop environment-specific default applications in a file named desktop-mimeapps.list where desktop is the name of the desktop environment (from the XDG_CURRENT_DESKTOP environment variable). For example, /etc/xdg/xfce-mimeapps.list defines system-wide default application overrides for Xfce. These desktop-specific overrides take precedence over the corresponding non-desktop-specific file. For example, /etc/xdg/xfce-mimeapps.list takes precedence over /etc/xdg/mimeapps.list but is still overridden by ~/.config/mimeapps.list.

Tip: Although deprecated, several applications still read/write to ~/.local/share/applications/mimeapps.list. To simplify maintenance, simply symlink it
$ ln -s ~/.config/mimeapps.list ~/.local/share/applications/mimeapps.list
. Note that the symlink must be in this direction because xdg-utils deletes and recreates ~/.config/mimeapps.list when it writes to it, which will break any symbolic/hard links
Note: You might also find files in these locations named defaults.list. This file is similar to mimeapps.list except it only lists default applications (not added/removed associations). It is now deprecated and should be manually merged with mimeapps.list.

Format

Consider the following example:

mimeapps.list
[Added Associations]
image/jpeg=bar.desktop;baz.desktop
video/H264=bar.desktop
[Removed Associations]
video/H264=baz.desktop
[Default Applications]
image/jpeg=foo.desktop

Each section assigns one or more desktop entries to MIME types.

  • Added Associations indicates that the applications support opening that MIME type. For example, bar.desktop and baz.desktop can open JPEG images. This might affect the application list you see when right-clicking a file in a file browser.
  • Removed Associations indicates that the applications do not support that MIME type. For example, baz.desktop cannot open H.264 video.
  • Default Applications indicates that the applications should be the default choice for opening that MIME type. For example, JPEG images should be opened with foo.desktop. This implicitly adds an association between the application and the MIME type. If there are multiple applications, they are tried in order.

Each section is optional and can be omitted if unneeded.

Utilities

While it is possible to configure default applications and MIME types by directly editing #mimeapps.list and the #Shared MIME database, there are many tools that can simplify the process. These tools are also important because applications may delegate opening of files to these tools rather than trying to implement the MIME type standard themselves.

If you use a desktop environment you should first check if it provides its own utility. That should be preferred over these alternatives.

The official xdg-utils contain tools for managing MIME types and default applications according to the XDG standard (xdg-mime). Most importantly it provides xdg-open which many applications use to open a file with its default application.

lsdesktopf

lsdesktopfAUR provides several methods of searching the MIME database and desktop MIME entries.

For example, to see all MIME extensions in the system's .desktop files that have MIME type video you can use lsdesktopf --gm -gx video or to search in the XML database files use lsdesktopf --gdx -gx video. To get a quick overview of how many and which .desktop files can be associated with a certain MIME type, use lsdesktopf --gen-mimeapps. To see all file name extensions in XML database files, use lsdesktopf --gdx -gfx.

Troubleshooting

If a file is not being opened by your desired default application, there are several possible causes. You may need to check each case.

Missing desktop entry

A desktop entry is required in order to associate an application with a MIME type. Ensure that such an entry exists and can be used to (manually) open files in the application.

Missing association

If the application's desktop entry does not specify the MIME type under its MimeType key, it will not be considered when an application is needed to open that type. Edit #mimeapps.list to add an association between the .desktop file and the MIME type.

Non-default application

If the desktop entry is associated with the MIME type, it may simply not be set as the default. Edit #mimeapps.list to set the default association.

Nonstandard association

Applications are free to ignore or only partially implement the XDG standard. Check for usage of deprecated files such as ~/.local/share/applications/mimeapps.list and ~/.local/share/applications/defaults.list. If you are attempting to open the file from another application (e.g. a web browser or file manager) check if that application has its own method of selecting default applications.

Variables in .desktop files that affect application launch

Tango-view-fullscreen.pngThis article or section needs expansion.Tango-view-fullscreen.png

Reason: The fact MimeType entries may be missing in the desktop files is only implied here, i.e. "Even if an application...", though this is a common cause of errors. Some openers may also associate mime types not explicitly listed in a desktop file (such as exo). Further environment-specific factors are at play, e.g. whether Terminal=true has an effect, though latter should arguably be expanded on in Desktop entries. (Discuss in Talk:XDG MIME Applications#)

Desktop environments and file managers supporting the specifications launch programs according to definition in the .desktop files. See Desktop entries#Application entry.

Usually, configuration of the packaged .desktop files is not required, but it may not be bug-free. Even if an application containing necessary MIME type description in the .desktop file MimeType variable that is used for association, it can fail to start correctly, not start at all or start without opening a file.

This may happen, for example, if the Exec variable is missing internal options needed for how to open a file, or how the application is shown in the menu. The Exec variable usually begins with %; for its currently supported options, see exec-variables.

The following table lists the main variable entries of .desktop files that affect how an application starts, if it has a MIME type associated with it.

Variable names Example 1 content Example 2 content Description
DBusActivatable DBusActivatable=true DBusActivatable=false Application interact with D-Bus.
See also configuration: D-Bus.
MimeType MimeType=application/vnd.oasis.opendocument.text MimeType=application/vnd.sun.xml.math List of MIME types supported by application
StartupWMClass StartupWMClass=google-chrome StartupWMClass=xpad Associate windows with the owning application
Terminal Terminal=true Terminal=false Start in default terminal