XDG Mime Applications

From wikinotes

Used to associate default programs to mimetypes.

Documentation

official docs https://specifications.freedesktop.org/mime-apps-spec/mime-apps-spec-latest.html

Tutorials

archwiki default applications https://wiki.archlinux.org/index.php/Default_applications
archwiki XDG mime https://wiki.archlinux.org/index.php/XDG_MIME_Applications

Locations (unix)

~/.config/mimeapps.list user-overrides to program/mimetype associations
/etc/xdg/mimeapps.list system program/mimetype associations
/usr/share/applications/*.desktop .desktop files for installed programs
/etc/mime.types All mimetypes defined for a system

Examples

/etc/mime.types


Associates mimetype to file extensions

# /etc/mime.types 
# (sample)
application/pdf              # pdf
application/pgp-encrypted    # asc pgp
application/pgp-keys         # key
application/pgp-signature    # asc pgp sig

~/.config/mimeapps.list


Links a .desktop with a mimetype.
Program will now be used by default to open mimetype.

# ~/.config/mimeapps.list (sample)
# SPACES BETWEEN '=' INVALID
[Default Applications]
application/x-extension-xhtml=userapp-Firefox-EVE7NX.desktop
application/x-extension-xht=userapp-Firefox-EVE7NX.desktop
application/pdf=userapp-evince-9LTCPX.desktop

/usr/share/applications/*.desktop


Describes programs installed on your computer, so that they can be launched.
These .desktop files can be associated to mimetypes (so a particular program opens mimetype by default).

ls /usr/share/applications/  (sample)
-rw-r--r-- 1 root root  4384 Jan 26 12:35 firefox.desktop
-rw-r--r-- 1 root root   968 Feb  5 10:40 flash-player-properties.desktop
-rw-r--r-- 1 root root   189 Dec 31 15:52 fluid.desktop

Usage

You may be interested in the xdg-utils cli command for interactively configuring this system.