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

Will return the .desktop file associated with the default app 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

    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 *

This site uses Akismet to reduce spam. Learn how your comment data is processed.