Search notes:

Shell command: xdg-mime

Determine MIME type of a file

With xdg-mime query filetype, the MIME type of a file (in the folllowing example: foo.pdf) can be determined:
$ xdg-mime query filetype foo.pdf
application/pdf

Determine the default *.desktop filename

Find the .desktop filename of the application which is registered to open application/pdf files:
$ xdg-mime query default application/pdf
okularApplication_pdf.desktop
Then:
$ grep Exec /usr/share/applications/okularApplication_pdf.desktop
Exec=okular %U
Compare with
file --brief --dereference --mime-type foo.bar

Change default application for a MIME type

$ xdg-mime default foo.desktop image/foo

See also

xdg-open and other Shell commands.
/usr/share/mime
XDG

Index