Furor Teutonicus blog | over | volg | teuto | lyme | archief | todo

⚠️ Deze website is recent overgezet van Wordpress naar Grav, en dat werk is nog niet afgerond. Hier en daar kunnen dus fouten of gebreken optreden. 🏗️ 🔧 🖥️

🕰️ 2013-12-03
✍️ Evert Mouw
⏱️ 2 min

How to add a custom filetype to Linux


If you are a Linux user, you might encounter the situation where you really want to add a custom filetype to your graphical environment. This article will help you do it without relying on specific tools, so it should work with all Linux distributions and in most graphical environments. I used Arch Linux with XFCE.

This post was earlier (2013-07-15) posted on TechMonks, of which I am a co-author.

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:

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="http://www.freedesktop.org/standards/shared-mime-info">
    <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 existingapplication-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.

MIME type editor

More resources:

Deze blogpost werd in december 2022 overgezet van WordPress naar een methode gebaseerd op Markdown; het is mogelijk dat hierbij fouten of wijzigingen zijn ontstaan t.o.v. de originele blogpost.