[Thunar-dev] mime-types detection

Jaap Karssenberg j.g.karssenberg at student.utwente.nl
Tue Jan 17 13:01:25 CET 2006


samuel verstraete wrote:

>I'm presenting you a problem i have with *all* file managers i tried
>uptill now...
>
>I'm working in a scientific sector and all our raw data (which are
>just text files) come overhere as .dat file (dat like in data, pretty
>logical... for a scientist like myself)
>
>Now of course i know that files with a .dat extension are supposed to
>be mpeg files (format/containers ,whatever)
>
>  
>
The correct way to fix this is to overload your mime-info database. This 
would solve the problem for all gtk/gnome filebrowsers (and also for kde 
in the future). You can define a new mimetype for "*.dat" for example in 
~/.local/share/mime/packages/mine.xml (see 
http://www.freedesktop.org/wiki/Standards_2fAddingMIMETutor for the 
details).

Once the filebrowser sees *.dat as another mime-type you can add your 
application of choice as the default program.

>But i thought that thunar was reading some kind of file header to
>detect the file type instead of just checking the file extension?
>  
>
The mime-info database specifies both file extensions and header 
matches. In general the extension is preferred because it is more 
transparent to the user and also because in certain cases it is actually 
more exact than the header. If you really want a header match for your 
data you can add the mimetype in the same way as above, just make sure 
to give your match a priority of 80 (not sure if thunar respects this 
feature of the mime-info spec).

Hope this helps.

-- Jaap <pardus at cpan>




More information about the Thunar-dev mailing list