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
.desktop
filename of the application which is registered to open application/pdf files: $ xdg-mime query default application/pdf okularApplication_pdf.desktop
$ grep Exec /usr/share/applications/okularApplication_pdf.desktop Exec=okular %U
file --brief --dereference --mime-type foo.bar
$ xdg-mime default foo.desktop image/foo