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.

wget https://gist.githubusercontent.com/acrisci/b264c4b8e7f93a21c13065d9282dfa4a/raw/8c2b2a57ac74c2fd7c26d02d57203cc746e7d3cd/default-media-player.sh

Run default-media-player.sh -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: default-media-player.sh mpv.desktop.

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