Set default application using `xdg-mime`

You can use the xdg-mime utility to query the default MIME type associations and change them.

xdg-mime query default video/mp4

This will return the .desktop file associated with the default app used to open MP4 files. To change the default association:

xdg-mime default vlc.desktop video/mp4

You need to specify the .desktop file to open files of the specified MIME type. To check the MIME type of a given file, use:

file -ib filename

2 thoughts on “Set default application using `xdg-mime`”

  1. Thanks. That said, no need to use file to get an application MIME file type here, since that also can be done with xdg-mime, using «query filetype» :

    $ xdg-mime query filetype /path/to/some_file.mkv
    video/x-matroska

    And if you do the same with file -ib, you get…

    $ file -ib /path/to/some_file.mkv
    text/html; charset=us-ascii

    which is… just wrong

Leave a Reply

Your email address will not be published. Required fields are marked *