Wednesday, October 16, 2024

How to update file types in Linux Mint

I have spent the last few hours trying various things to update the .odin file type associations in Linux Mint.  Here is what I found that actually worked.

Open /usr/share/mime/packages as root.

Create a new file called your-file-type.xml.  The one I created is: x-odin.xml
(The "x-" follows an established pattern for programming source code.)

Inside this file, have text similar to the following, but with your information replacing the bits in color:

<?xml version="1.0" encoding="utf-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
  <mime-type type="text/x-odin">
    <comment>Odin source file</comment>
    <generic-icon name="OdinO"/>
    <glob pattern="*.odin"/>
  </mime-type>
</mime-info>


The "glob pattern" line is where you associate the file extension.  "*.odin" means any file ending with ".odin".

Place various sized versions of the icon you want to use in the various size folders in: /usr/share/icons/theme-name/mimetypes.  In my case, that's /usr/share/icons/Mint-Y/mimetypes.  Make sure the icons are all named the same as the whatever you use in the generic-icon-name line above.  .png files seem to work well, but make sure you create a large one, and then scale it down to the various sizes (16, 24, 32, 48, 64, 128 pixels).

Once you've done all that, open a terminal in the /usr/share/mime/packages folder and type (replace x-odin with your file name):

    sudo xdg-mime install --mode system x-odin.xml

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


Once the system has finished updating, behold your newly associated file type with its lovely, hand-crafted icon.  Now, all you have to do is associate the file type with a program to open it.  That's done by right clicking on an appropriate file, selecting "open with", "other application", choosing the proper application, and then clicking on "set as default".

That's all you have to do.  Why is it this convoluted?  I'm guessing historical reasons, as in they made it up as they went along.  Simple is much, much more difficult to achieve than complex.

No comments:

Post a Comment

I reserve the right to remove egregiously profane or abusive comments, spam, and anything else that really annoys me. Feel free to agree or disagree, but let's keep this reasonably civil.