Jul 15, 2013 -- posted by Evert Mouw
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-deleteall/> <glob pattern="*.mht"/> <glob pattern="*.MHT"/> <glob pattern="*.mhtml"/> </mime-type> </mime-info>
And we have to update the MIME database:
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.