0

I am trying to associate .fig files (generated by MATLAB) so that I can open them easily by double clicking them. An easy way of doing that in Ubuntu versions before 16.04 is to use the custom command option after installing Ubuntu-Tweak tool (https://stackoverflow.com/questions/4544342/open-matlab-figure-in-ubuntu , Add custom command in the open with dialog?).

Ubuntu 16.04, however, does not have the Ubuntu-Tweak tool. I tried solutions which do not need the tweak tool, but those approaches do not work (like this). How can I set a custom command for files with a particular extension in Ubuntu 16.04?

2
  • ubuntu-tweak should be available for 16.04 as well, I think...
    – Byte Commander
    Jul 19, 2016 at 8:49
  • See the answer here specific to 16.04 (and the other answers to that question as well) to find out how to install Ubuntu Tweak: askubuntu.com/a/781586/367990
    – Byte Commander
    Jul 19, 2016 at 8:59

1 Answer 1

0

I don't like unofficial repos, so I did it manually, in my case with truecrypt. I think you can use

The 1st step is: Is there any related MIME type exists? I tried to find the .tc extension or the truecrypt text:

grep -i -e "\.tc" /usr/share/mime/packages/*
grep -i -e "truec" /usr/share/mime/packages/*

I didn't find anything, so I created it into /usr/share/mime/packages/truecrypt.xml

<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
    <mime-type type="application/x-truecrypt">
        <comment>TrueCrypt encrypted file container</comment>
        <icon name="truecrypt"/>
        <glob-deleteall/>
        <glob pattern="*.tc"/>
    </mime-type>
</mime-info>

I found 3 matches for the .fig extension (under the image/x-fig MIME type by freedesktop, and under application/x-cabri in kde.xml) so I think you don't need to create this, but someone may find it useful.

In my case the truecrypt.desktop file did not contain any MIME type info, so I added this mime type to the end of the file: /usr/share/applications/truecrypt.desktop

MimeType=application/x-truecrypt

My new MIME type was not associated with any program, so I added this line to the end of the default file, which is in /usr/share/applications/defaults.list

application/x-truecrypt=truecrpyt.desktop

If your MIME type existed, I think you need to change this association instead of creating one more.

At last update the databases:

sudo update-mime-database /usr/share/mime
sudo update-desktop-database

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .