Nautilus 2.6 and mime types

Since I installed Gnome 2.6 in my Debian testing laptop, nautilus has refused to work with certain file types. They are classified as application/octet-stream and not application choices are offered.
Even if I go to Applications | Desktop Preferences | Advanced | File types and programs and set up the mime types, extensions and applications, nautilus couldn’t care less. These settings are almost ignored.
I’m not an expert on these matters, but it has something to do with the content-sniffing nautilus does to determine the file type.
It took a while to figure out, but I have found the way to add file types to the system. It is described at
First one has to create an XML file for the type or types to be added. The format is quite simple, and here is one for the Glabels application for printing address labels:

<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="">
    <mime-type type="application/x-glabels">
        <comment xml:lang="en">Glabels document</comment>
        <glob pattern="*.glabels" />

Notice the mime-type, the description and the glob-pattern. There’s also a way of specifying magic patterns for content sniffing.
It is possible to have several “mime-type” sections in the same file.
The XML file is placed in /usr/share/mime/packages/, in this case I called it glabels.xml.
When this file is in place, all that remains is to run the command

update-mime-database /usr/share/mime

which will populate /usr/share/mime with separate files for each mime type, including the new types.
All that remains is to restart nautilus by running nautilus --quit from a shell prompt, and the new mime-type should be recognised.
UPDATE 2004-07-17: It appears you can have your private mime-files in ~/.local/share/mime. Create, e.g., ~/.local/share/mime/packages/local.xml in the format described above, with one or more ‘mime-type’ entries, and run the command

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

as yourself. It will then populate ~/.local/share/mime/ with all the necessary files for nautilus to recognise your new mime-types, after a restart, that is.


2 responses to “Nautilus 2.6 and mime types”

  1. T-H-A-N-K YOU!!
    Finally, !! I cant believe I fixed this piece of shit, ahh how can I thank you, or google, hehe, thanks god the Mime system is getting rewritten all according to Fdesktop standards for 2.8, I love you man, thanks!

  2. Nice!

    Reminds me of the old Steve Wright routine: I have the world’s largest collection of seashells. You may have seen it; I keep it on the beaches all over the world.

    (Gnome has the world’s best documentation … it’s on blogs all over the web.)

Leave a Reply

Your email address will not be published. Required fields are marked *