Wednesday, September 23, 2009

Fixing unrecognized File Type extensions in Ubuntu

I've had a little 'bug' in my Ubuntu for the past month that was annoying me a bit. I use TeXmacs for creating/editing small LaTeX documents. The problem is that Nautilus was incorrectly detecting the file type of .tm files, thinking they were plain text documents (see image below). The consequence is that TeXmacs files would be opened in gedit (or the default text editor) when opening them through the Nautilus file browser.



The first solution attempt was right-clicking a .tm file, going to "Properties -> Open With" and changing the default application to GNU TeXmacs. This was a disaster, since now *all* plain text files would be opened in GNU TeXmacs, since Nautilus genuinely believed a .tm to be the same as a .txt and thus changed the default application for all text files.

My second attempt at a solution (after googling a bit) was checking the MIME file type associations, which is the way Ubuntu associates an extension to a file type. The info is all in the file /etc/mime.types. However, to my disappointment, this file already contained a mime type for TeXmacs documents, indicated by the entry
"text/texmacs tm ts". So even though the mime type was correctly recognized, it seems Nautilus wasn't picking it up. This could be further deduced from the fact that running the command file on a .tm document in the terminal returned the correct mime type.

After more googling, I finally discovered that this is in fact a bug and found a fix for it:

http://savannah.gnu.org/bugs/?25938#discussion

Essentially, you manually create an xml file describing the TeXmacs mime type to /usr/share/mime/packages and then manually update the mime database of the system (setting an icon for the file type is optional, but may be useful).

NOTE:
the original poster of the above bug fix made a small typo: an extra semicolon (;) at the end of the line containing "mime-info xmlns=" Remove it before trying to update the mime database.

After this is done, logout / re-log (or simply kill / restart nautilus from the terminal) and the new file extension should now be recognized:



The nice thing about this is that it should conceivably work for any other file type that has a correct mime type in /etc/mime.types but is not being recognized by Nautilus.

Hope this was helpful ;).

9 comments:

Anonymous said...

Malaysia & Singapore & brunei best online blogshop for wholesale & supply korean accessories, accessories, earstuds, choker, rings, bracelet, hair & bangle add-ons.
Promotion 35 % wholesale rebate. Ship Worldwide
Also visit my webpage ; ways to get ripped

Anonymous said...

Terrific article! This is the type of info that are supposed to be shared around the internet.

Shame on Google for no longer positioning this submit upper!
Come on over and discuss with my site . Thanks =)
Also visit my web-site - need a winter garden florida building company

Anonymous said...

This excellent website certainly has all the information and facts I wanted concerning this subject and didn't know who to ask.

Here is my web blog: Brunette really likes sex

Anonymous said...

What's Taking place i am new to this, I stumbled upon this I have discovered It positively helpful and it has aided me out loads. I am hoping to contribute & assist other customers like its helped me. Great job.

Here is my weblog :: http://www.xxxvideofix.com/

Anonymous said...

If some one needs to be updated with newest technologies
therefore he must be go to see this web site and
be up to date everyday.

Also visit my web blog: http://www.pornoblack.org

Anonymous said...

Informative article, just what I was looking
for.

Visit my blog post :: http://www.69videosporno.net/nakedamateur-teen-caps

Anonymous said...

My family all the time say that I am wasting my time
here at web, except I know I am getting know-how daily by reading thes good articles.


Here is my homepage Pilates Exercises

Anonymous said...

excellent issues altogether, you simply gained a new reader.
What would you suggest about your put up that you just made some days in the past?

Any positive?

Here is my web blog :: Marie

Anonymous said...

Keeping a keen eye on the scale will alert you
to unhealthy patterns. The riser handlebars of these bike sports are fantastic
for comfort. The biker will wear the sponsor's gear and promote products and services
in exchange for training, financial support, and other
terrific perks.

My site ... mad skills motocross 2 cheats