[ubuntu-za] Strange Nautilus behaviour.

Peter Nel fourdots at gmail.com
Fri Dec 30 18:37:17 UTC 2011


>
> ...
> I have (temporarily?) fixed my .pdf problem by manually editing the
> file ~/.local/share/applications/mimeapps.list and changing the line -
> ...
> application/pdf=evince.desktop;gimp.desktop;FBReader.desktop;inkscape.desktop;gpdftext.desktop;
>
> But I am a bit wary of that file as I don't quite understand how it
> works (I don't think that Gimp should be there!).
> ...
> Any ideas about why Nautilis is not doing this itself?
>
> Thanks,
>  Bill
>

Hi Bill,

Yes, I don't know why the ability to change the default app to open a
file-type with was removed.
A bit irritating frankly.

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 :-)

The following lists some common mime types:
text/html
image/gif
image/png
image/jpg
video/mpg
... etc.
So the first part of each line specifies the mime-type. The second
part, after the " = " lists (in order of preference) the apps that can
open files of that type.
You can also see that each of the listed items has a ".desktop"
extension, that's because the list is actually a list of files
(text-based files each defining a "launcher" file... the same stuff
you can drag & drop onto the Unity launcher to run programs; i.e. each
Unity launcher icon is also a .desktop file)

The system-wide location for these .desktop files is:
/usr/share/applications/
When you do a search in the dash, this is where it finds the programs;
so, you actually click one of those .desktop files in the results to
launch it. Same if you use the lenses, etc.

There's also a system-wide mime-type association file in that same
directory called 'mimeinfo.cache':
/usr/share/applications/mimeinfo.cache

Each user can have their own custom launchers (".desktop" files), or
override existing ones under:
~/.local/share/applications/
(FYI: " ~ " is shorthand for the current user's home directory, e.g.
/home/peter/)

Similarly, each user can also override the default mime-type
associations, in that file you mentioned (that you changed for PDF's):
~/.local/share/applications/mimeapps.list
I believe this file is where nautilus gets it's preferred application
info from, and where it used to override it when we selected "Always
use this application".

Hope this made sense. It's simple really.


Péter Nel

P.S. One down side of using mime-types is that it recognizes my .jar
(java bundles), and .mwb (mysql workbench) files as .zip files,
because they're actually PK-zipped (mime:application/zip?); if I
change the associations, I get the reverse problem.
Has anyone got a solution for this?



More information about the ubuntu-za mailing list