Ubuntu – How to set default application for a specific file extension

defaultdefault-programsfiles

I am trying to set meshlab as the default application to open .obj files.

I attempted (as mentioned in here) right click a random obj file -> properties -> Open With -> there is no meshlab to choose from and there is no way I can add meshlab into it.

The weird thing is when I do the same step for .ply file, there actually is an option to choose meshlab to set as the default application.

Now I need to open meshlab first, and drag the obj file in it, which is a lot more hassle than just double clicking the obj file to open it.

What should I do so I can open .obj files with meshlab by default?

Best Answer

First, run mimetype on your file to get the mimetype as follows:

$ mimetype bunny.obj 
bunny.obj: application/x-tgif

Once you've determined the corresponding mimetype, add your application as the default in /usr/share/applications/defaults.list:

$ sudo su
$ echo "application/x-tgif=meshlab.desktop" >> /usr/share/applications/defaults.list

It's important to use two > symbols in the command above, not one. Consider making a backup of /usr/share/applications/defaults.list beforehand as well.

Related Question