Have a way to dynamically change software associations at distribution level

Didier Roche didrocks at ubuntu.com
Tue Aug 4 00:16:47 PDT 2009


Hello everyone,

Right now, GNU/Linux distributions (Debian, Ubuntu, from what I see it
seems to apply to Fedora, OpenSuse and Mandrake as well…) use a static
defaults.list file in $XDG_DATA_DIRS/applications shipped by the
distribution for associating a mimetype to a default application. We
currently, for Ubuntu, symlink it to /etc/gnome/defaults.list.
Consequently, we set a software as the default distribution default
dvd player for example. That means as well that if a user buy a better
player with codec they don't get this one used by default without
changing user's personal preferences. We want to change the system to
have a priority number rather than a default hardcoded, ie powerdvd
would have a higher priority than totem (for Ubuntu for example) so it
will be used when installed.

To handle application priorities, the idea is to rely on the .desktop
files having an optional InitialPreference=<Priority> (similar key to
what KDE is using), a default priority will be used if there is no
such key. We can setup a 100 priority for application currently
present in defaults.list for distros, and 50 as the default priority
if the key is not present in the .desktop file.

This is a proposal for changing
http://www.freedesktop.org/wiki/Specifications/shared-mime-info-spec
and http://www.freedesktop.org/wiki/Specifications/desktop-entry-spec
specifications to handle those use cases. The main goal is to keep
retro-compatibility for people who don't want to change their
defaults.list. As we don't change the current layer of user choice in
$XDG_DATA_HOME > defaults choice in $XDG_DATA_DIRS/applications, I
will just emphasize about defaults.list and the cache: The priority
order would be:

    * mimeapps.list for sysadmin
    * defaults.list for distro and compatibility (at the end,
distribution wanted to use this dynamic association will no more ship
it)
    * mimeinfo.cache autobuilt

Updating mimeinfo.cache file will be made as of today, when executing
the shared-mime-info update-desktop-database tool. It will order the
list of desktop file in the same order than the priorities in desktop
files.

That would mean with that example:

    * application/ogg=gnome-mplayer.desktop;vlc.desktop;kde4-amarok.desktop;mplayer.desktop;rhythmbox.desktop;totem.desktop;

gnome-mplayer.desktop priority < vlc.desktop priority < kde4 amarok <
mplayer < rhythmbox < totem

We want also to take into account the current desktop environment. For
instance, with this example, if you are running KDE, the distribution
default choice (if no user choice is setup) would be totem instead of
amarok. To avoid this issue, categories will be used to prefer the
application matching the desktop when there are several choices (ie
KDE category when using KDE. Consequently, amarok will be used in a
KDE environment and totem in the GNOME one, if the user doesn't change
his/her own preferences). That would mean that we open the "default
candidate" .desktop file to see if we fit the current environment. If
not, we head to the previous one of the list, open the .desktop file…
So, the default choice rule (if the user didn't change anything and
the distro don't ship a defaults.list for this mime type) will be: the
last .desktop application file found in the list corresponding to my
mime type, having a category corresponding to my current desktop
environment. If no .desktop file corresponding to the current
environment is found, we fallback to the last entry.

What do you think about it? I only take a look at glib (more
precisely, the gio module) and update-mime-info and the code to write
to achieve that goal seems minimal.

Didier


More information about the xdg mailing list