technology and zen of life

“A heisenbug (named after the Heisenberg Uncertainty Principle) is a computer bug that disappears or alters its characteristics when an attempt is made to study it.”

How to add a custom filetype to Linux


In this example, we will add support for MHTML / MHT files.

Note that the MIME type for MHTML is not well agreed upon. Used MIME types include:

  • multipart/related
  • application/x-mimearchive
  • message/rfc822

According to a StackOverflow question, message/rfc822 should be used. A recent discussion on FreeDesktop, however, recommends application/x-mimearchive as a subtype of multipart/related. I will use message/rfc822 in the examples below and have added this unclarity to the Wikipedia article.

Add a custom MIME type

This adds a custom MIME type for the current user.

First, we open a new file:

cd ~/.local/share/mime/packages

vi message-rfc822.xml

The contents should be these:

<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="">
    <mime-type type="message/rfc822">
        <comment>MHTML web archive</comment>
        <icon name="application-rss+xml"/>
        <glob pattern="*.mht"/>
        <glob pattern="*.MHT"/>
        <glob pattern="*.mhtml"/>

And we have to update the MIME database:

update-mime-database ~/.local/share/mime

Add a custom icon

In the MIME type added in the example above, I used the existing application-rss+xml icon for the MHTML files. You might want to edit the icon. That icon needs to be stored somewhere in the ~/.icons directory. For example, when using the Roedor icon set, see:


After editing the icon, upate the icon cache:

gtk-update-icon-cache -f -t ~/.icons/Roedor

It is also possible to use a generic icon, independent of the theme being used, by setting an override. I have not explored this further because I did not need it, and because I saw fragmented and insonsistent information about this on the web.

Set the application used to open the MIME filetype

Changing the application used for opening files with this MIME type depends partly on the desktop environment used.

In XFCE, for example, go to Applications –> MIME Type Editor, or right-click a file.

More resources:

About Evert Mouw

Interested in kinda everything, studied political science, now studying medical informatics. MCSE, Linux enthousiast, and believing that technology is the path to enlightenment ;-) Best RTS game ever is Warhammer Soulstorm (IMHO). Other hobbies include hiking, kayaking, reading and when I have time, trying to have an ant colony in an artificial nest (formicarium).

Email Subscription


The views expressed on this blog are personal. We do not claim to be a representative voice of the views of any organisation whatsoever. We are not responsible for the content present on the blogs to which we have linked.Views expressed are solely that of the author and does not reflect a collective opinion of contributors.
%d bloggers like this: