‘Unity’ desktop comes with a utility that lets us set the default application for opening certain file types. For example, by using this tool, one can change the default Web browser, Text editor, Image viewer, Audio player, Video player etc.
Now most programs, while installing, if they are related to one of those available categories, they automatically add themselves, and thus, we can easily make them the default application for opening those file types. However, this does not always work.
For example, when installing, ‘mplayer’ (the command-line based one) does not add itself to this list. This is understandable, as it is a command-line based one and most users won’t be using as the default media player.
Nevertheless, by using a simple trick, one can easily add ‘mplayer’, or any other player that does not add itself into this list. In this article, I’m concentrating on adding a new program for handling audio/video categories only.
Now as you know, the default media player in Ubuntu is called ‘Totem”. And by using its existing desktop entry file, called ‘totem.desktop’ (stored in ‘/usr/share/applications’), I have created a custom desktop entry file, that can be used to add any media player into the default application list for Audio and Video formats.
In other words, you can use this file to set a desired application as the default one for opening all the audio/video files, easily.
So, first of all, download the configuration file from here (it is compressed, once the download completes, make sure to extract the file into your ‘Home’ folder).
Now open ‘Gedit’ text editor and open the extracted file (‘custom-media-player.desktop’) using it.
Now all you have to do is;
1: Give a name under the ‘Name‘ field. You can enter any name here (it does not have to be the name of the program), and it will be used as the entry name listed on the ‘Default Applications’ (the tool that lets us change the default applications) menu.
2: Under the ‘Exec‘ field, enter the command of the program, do not change the ‘%U’ argument.
For example, if I wanted to execute ‘mplayer’, then I’ll replace the ‘enter-the-exact-name-here’ text field with ‘mplayer’ and the output will look like below.
3: If you want an icon to be displaced on the menu entry, then simply enter its path under the ‘Icon‘ field, or else, leave it blank.
When you are done, make sure to save the changes and then close the editor.
Now, assuming the file is in your ‘Home’ folder, enter the below command to move it into the ‘/usr/share/applications’ folder.
sudo mv custom-media-player.desktop /usr/share/applications
For the newly added ‘desktop entry’ to be added into the ‘Default Applications’ utility, we have to update the ‘desktop entry cache’. For that, use the below command.
That is it.
Note: You can open-up the ‘Default Applications’ dialog box by going over to: ‘System Settings’ -> ‘Details’ -- ‘Default Applications’ (once this is clicked, you should see your newly added program under the drop-down list of ‘Audio’ and ‘Video’ options).