xdg-mime(1)
Query and set MIME type associations for files and URLs on the desktop.
Synopsis
xdg-mime query [filetype|default] MIME-TYPE
xdg-mime default APPLICATION MIME-TYPE...
xdg-mime install [--mode MODE] [--novendor] MIMETYPES-FILEDescription
xdg-mime is used to query MIME type information and set default applications for handling specific MIME types on freedesktop.org-compliant desktops. It provides a uniform interface across different desktop environments like GNOME, KDE, and others.
Common tasks include looking up what MIME type a file has, finding the default application for a MIME type, and setting a new default application for handling particular file types.
Common options
| Flag | What it does |
|---|---|
query filetype FILE | Output the MIME type of the specified file |
query default MIME-TYPE | Output the default application for the given MIME type |
default APPLICATION MIME-TYPE | Set APPLICATION as the default handler for MIME-TYPE(s) |
install [--mode MODE] | Install MIME type definitions from a .xml file (user or system mode) |
--novendor | Skip the vendor prefix when installing MIME types |
Examples
Check the MIME type of a PDF file (outputs application/pdf)
xdg-mime query filetype document.pdfShow which application is currently set as the default PDF handler
xdg-mime query default application/pdfSet Firefox as the default application for HTML and XHTML files
xdg-mime default firefox.desktop text/html application/xhtml+xmlSet GNOME Files (Nautilus) as the default directory opener
xdg-mime default org.gnome.Nautilus inode/directorySet VLC to handle MP4 and Matroska video files by default
xdg-mime default vlc.desktop video/mp4 video/x-matroskaInstall custom MIME type definitions in user-specific configuration
xdg-mime install --mode user custom-mimetypes.xml