[ubuntu-za] Strange Nautilus behaviour.
Peter Nel
fourdots at gmail.com
Sat Dec 31 15:05:55 UTC 2011
> On 30/12/2011 20:37, Peter Nel wrote:
>> In linux file associations are based on "mime type" (the structure of
>> the file contents) and not the file extension like .zip, .doc, etc.
>> (with exceptions) as in windows (perhaps it was added to linux to make
>> windows users feel at ease?).
>>
>> That's why you actually don't need the .xyz extension after a file
>> (try it: create and save a new .odt document with LibreOffice, close
>> LibreOffice, then delete the ".odt" file extension in the file name...
>> Nautilus still recognizes it as and .odt file and will open it with
>> LibreOffice when you open it. Cool huh :-)
>
> Actually, that's not quite right. The mime types are a list of types of
> files (it's a text list), with all applicable file extensions associated
> with the mime type.
>
> What happens on Linux is that the extension is first looked at to
> determine the mime type, and failing that, the file contents are studied
> to try to determine the file type. Of course this doesn't always work.
You are correct.
I looked further into the extension vs. mime association issue -
Here are some notes...
/* - - - -
Filename extentions are not strictly required in Unix-based systems,
it's a convention adopted from DOS for convenience mostly. In wnidose
the dot "." character is treated as a file's "namespace" seperator, in
Unix it's just another character. Windows needs them, Linux doesn't
(linux does use them, but does not rely on them - is my point --
thought there are exceptions (as described below), just to keep things
interesting
I tested a mimeless file-extension scenario by creating an empty dummy
file in nautilus and appending the extension ".odt" to the name, and
Nautilus picked it up as a LibreOffice file.
- - - - */
I read this informative man-page on how extensions are associated with
mime-types in gnome:
http://manpages.ubuntu.com/manpages/hardy/man5/gnome-mime.5.html
TIP:
You can check a file's mime-type with the command 'file', e.g.:
$ file -bi db.mwb
application/zip; charset=binary
> P?ter, with your JAR files, you'll probably find that your default
> archive application is associated with them (because they are just zip
> files).
I know this was my problem :-) I was looking for a solution. But this
thread actually lead me to look deeper into it.
I discovered that I'd already solved this problem of mine using
Bruce's technique months ago; i.e. I double-click a .mwb file and it
opens it in the correct application.
I was still boggled though - Finding no trace of "mwb" in any of the
other files I looked further, and found it in:
~/.local/share/applications/mimeapps.list
as:
application/x-extension-mwb=userapp-mysql-workbench-ELVBTV.desktop;
application/x-trash=userapp-mysql-workbench-ELVBTV.desktop;
By specifying the "Open With" application in nautilus, it seems the
above entries and an "mime-override"-to-extension mapping file was
created:
~/.local/share/mime/application/x-extension-mwb.xml
- - -
<mime-type xmlns="http://www.freedesktop.org/standards/shared-mime-info"
type="application/x-extension-mwb">
<comment>mwb document</comment>
<glob pattern="*.mwb"/>
</mime-type>
- - -
Contrary to my initial statement, in this case the file extension is
actually required for this to work, since the actual mime-content
inside the file is "application/zip" - thus if I remove or change the
extension, the file will open in file-roller.
It goes further than this, but that's the gist of it.
Fascinating.
> --
> Raoul Snyman, B.Tech IT (Software Engineering)
--
Péter Nel
More information about the ubuntu-za
mailing list