Setting a Default Media Player in Linux

Setting a default media player in Linux in a general way is surprisingly difficult to do. The XDG specification for default applications is located here. Default applications are configured in ~/.config/mimeapps.list which is an ini configuration file. The [Default Applications] entry of this file controls the default applications for the user for the given mime type in the form $MIME=$APPLICATION where the application is one of the desktop entries in /usr/share/applications. A desktop entry should be installed there by your media player package.

I’ve made a script to make this a bit easier.


Run -l to list all the candidate media player desktop files on your system. Then pick one and set it as the default by passing it as the first argument. For example: mpv.desktop.

The script can be found here. Let me know if this is useful for you in the comments.