LinuxCommandLibrary

xdg-mime

Query and manage MIME type associations

TLDR

Display the MIME type of a file

$ xdg-mime query filetype [path/to/file]
copy
Display the default application for opening PNGs
$ xdg-mime query default image/png
copy
Display the default application for a file's MIME type
$ xdg-mime query default $(xdg-mime query filetype [path/to/file])
copy
Set an application as default for specific MIME types
$ xdg-mime default [imv.desktop] image/png image/jpeg
copy

SYNOPSIS

xdg-mime command [arguments]

DESCRIPTION

xdg-mime queries and manages MIME types according to the XDG (freedesktop.org) standard. It can detect file types, query default applications, and set application associations.
The tool integrates with the desktop environment's MIME type handling, storing user preferences in ~/.config/mimeapps.list.

PARAMETERS

query filetype _file_

Display the MIME type of a file
query default _mimetype_
Display the default application for a MIME type
default _application_ _mimetype_...
Set default application for MIME types
install _mimetypes-file_
Install a MIME type definition
uninstall _mimetypes-file_
Uninstall a MIME type definition

CAVEATS

Application associations use .desktop file names. Changes may require restarting applications to take effect. Works with XDG-compliant desktop environments.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard