Default Program | File Association
David Faure
dfaure at trolltech.com
Fri Jan 25 02:21:51 PST 2008
On Friday 25 January 2008, Alexander Larsson wrote:
> The apps files list the mime types they support in their desktop files,
> this info is extractted out into a "mimeinfo.cache" file in each
> directory with desktop files listing for each mimetype a list of desktop
> files. The order of the lists in this file is to my knowledge
> essentially random.
OK - just a cache, so this is an implementation detail.
(we have ksycoca for this in KDE).
> In each directory with desktop files we also have a "defaults.list" file
> which is similar to the mimeinfo.cache file. It lists for each mimetype
> the default apps to use for it as a list of desktop file names that are
> to be looked up in the order specified (as some might not exist, or be
> marked as ignored for one particular desktop or in general). This file
> looks something like:
>
> [Default Applications]
> application/x-dia-diagram=fedora-dia.desktop
> application/x-bzip=gnome-file-roller.desktop
> image/jpeg=gnome-eog.desktop;gthumb.desktop;
> ...
Excellent, this is more or less what I was missing.
After discussion with Alexander on IRC we came to the following adjustement:
* being able to add an application to a mimetype in defaults.list even if the application
.desktop file does not mention this mimetype. This removes the need for making local
copies of desktop files.
* being able to remove associations, in the defaults.list file, using a separate group like this:
[Removed Associations]
image/x-xwindowdump=kview.desktop;
This way the app-mime association list is fully editable (you can add and remove),
and no duplication of system settings is done (so if the sysadmin updates his higher-level
defaults.list you'll still get those changes, except for the associations that have been
explicitely removed this way).
> To change the default app for a mimetype, all we have to do is update
> ~/.local/share/applications/defaults.list, adding the desktop id at the
> front of the list for the mimetype (and deleting any previous mention of
> it in the rest of the list.
OK.
> To add support for a new mimetype to a desktop file
... we will only need to add it to ~/.local/share/applications/defaults.list,
no more .desktop file duplication.
And to remove support for a mimetype to a desktop file,
if it's listed in ~/.local/share/applications/defaults.list only then we just remove it from there.
otherwise (if more global defaults.list files list it, or if the .desktop file mentions it), we add it
to [Removed Associations]. OK might be simpler to always just do the latter :-)
Note: the list of removed associations has to be honoured when falling back to
"the associations defined in the .desktop files" of course (e.g. ignoring kview.desktop
when looking for apps that handle image/x-xwindowdump, in the example above).
--
David Faure, faure at kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).
More information about the xdg
mailing list