Have a way to dynamically change software associations at distribution level

Stanislav Brabec sbrabec at suse.cz
Tue Sep 1 05:35:41 PDT 2009


Didier Roche wrote:

> Can you please explain a little bit your heuristic to produce your default list?

Collect all desktop files that announce support for a MIME type in
question. Then first match wins:

1. desktop file is configured in /etc/desktop-defaults.conf (or
desktop-defaults.conf.d) as default for MIME type.

2. desktop file is configured as preferred default
in /etc/desktop-defaults.conf (or desktop-defaults.conf.d).

3. desktop file is configured as plain default
in /etc/desktop-defaults.conf (or desktop-defaults.conf.d).

4. desktop contains correct combination of SuitedFor and
SuitedForMime/NotSuitedForMime (not yet implemented in a patch sent last
week, but it should be easy to do).

5. Related Categories match

6. No specific match

If there are more matches in the same level, then the application that
contains key listed earlier in the configuration wins. If there are more
equal matches, first found application is used (pseudo-random).

Problems of the algorithm:

Experiments show, that one level of preference is not sufficient. That
is why I introduced two levels (default, preferred default). Use a
number (something like InitialPreference, but applied in the central
configurarion file) may be better.

The algorithm is used successfully in SuSE for several years in an ugly
form of /sbin/conf.d/SuSEconfig.glib2. In past, we used a static
defaults.list, but we always forgot to define file-roller for some
obscure archive format and so on. That is why we decided to generate it.

See the end of the mail for the example of the minimalistic default
configuration.

> Aslo, XDG_DESKTOP_PREFIX is approximately the same than Alexander's
> proposal of XDG_CURRENT_DESKTOP we integrated into the spec (and yes,
> we can use it in defaults.list).

Yes. XDG_DESKTOP_PREFIX may be "${XDG_CURRENT_DESKTOP}-". We also may
think about XDG_MENU_PREFIX, that may be tried as
"${XDG_CURRENT_DESKTOP}-" first.

> So, with your use case, if we take static configuration file in the
> algorithm, let's say that Totem is the best one on the default
> desktop, it will use it has it's on the configuration file, but if you
> bye a DVD player that is not in this intial list from default
> applications (based on your distribution), how can you integrate it so
> that it's been associated by default?

Without a global static configuration file, totem will be probably
selected as default in future GNOME, as it will be the only application
that contains SuitedFor=GNOME; and opens video and audio files.

Edit say /etc/desktop-defaults.conf.d/my.conf and add lines:

To make it a default DVD player in all desktops:

[Desktop Defaults]
x-content/video-dvd=BestDVD.desktop

To make it a default DVD player for GNOME:

[GNOME]
x-content/video-dvd=BestDVD.desktop

To make it a default player for everything everywhere:

[Desktop Defaults]
Default=BestDVD.desktop

To make it a default player only for formats that totem cannot play:

[Desktop Defaults]
Preferred=totem.desktop
Default=BestDVD.desktop

> And I don't see how you fix this issue with your proposal:
> > "openSUSE Desktop GNOME" needs Nautilus as a default file browser.
> > "openSUSE Mobile GNOME" need Clutter as a default file browser.
> > Both should be done without modifying of Nautilus or Clutter desktop
> > files.

Use /etc/desktop-defaults.conf with:

[GNOME]
Default=nautilus-folder-handler.desktop

[MobileGNOME]
Default=clutter.desktop


Here is an example of a simple configuration file for standard GNOME:

[Default Applications]
# No applications are defined as default everywhere.

# Define defaults for GNOME
[GNOME]
# Prefer applications that contain these Categories:
# After implementing of "Inherit", just a "GNOME" may be sufficient.
Categories=GNOME;GTK;
# Inherit definitions in [GTK] section (not yet implemented)
Inherit=GTK
# These applications are good defaults for GNOME
# (In future, SuitedFor may simplify this list)
Default=eog.desktop;evince.desktop;gedit.desktop;file-roller.desktop;nautilus-folder-handler.desktop;MozillaFirefox.desktop;totem.desktop;
# eog is better default for TIFF than evince
image/tiff=eog.desktop

[GTK]
Categories=GTK;
# GQView is a good default for non-GNOME GTK+ based desktops
Default=gqview.desktop;

[XFCE]
Categories=XFCE;
Inherit=GTK;
# Define some good defaults for XFCE here:
Default=...

And here is an example of a customized desktop that is equal to GNOME,
but uses clutter as a file browser:
[MobileGNOME]
Inherit=GNOME;
# nautilus is "Default" in GNOME. To win, clutter must be "Preferred".
Preferred=clutter.desktop;


Reference:
http://lists.opensuse.org/opensuse-gnome/2009-07/msg00011.html
https://bugzilla.novell.com/show_bug.cgi?id=456026

-- 
Best Regards / S pozdravem,

Stanislav Brabec
software developer
---------------------------------------------------------------------
SUSE LINUX, s. r. o.                          e-mail: sbrabec at suse.cz
Lihovarská 1060/12           tel: +420 284 028 966, +49 911 740538747
190 00 Praha 9                                  fax: +420 284 028 951
Czech Republic                                    http://www.suse.cz/



More information about the xdg mailing list