The update-alternatives command is a common way to specify which of various alternative programs should be the default in each of several categories of programs (web browsers, editors, etc). I think that the normal way for a user to change defaults is to run something like sudo update-alternatives --config gnome-www-browser
though various apps rely on other ways of specifying default browser (see e.g. 'xdg-open').
But my question here focuses on meaning and policy around the priority
configuration setting. The man page explains:
Each alternative has a priority associated with it. When a link group is in automatic mode, the alternatives pointed to by members of the group will be those which have the highest priority.
It also notes that Different packages providing the same file need to do so cooperatively.
I'd like to understand how these priorities are designed to work:
- Who determines the priorities?
- Are users ever expected to modify them?
- When packaging a program, how should these priorities be set?
- Is there an easy way to see the priorities that all the Ubuntu packages use for each alternative, as a guideline for current practice? I imagine that's easier for official packages than for those in add-on repos, but given a repo, I imagine that it could also be queried.
- What expectations should we have for organizations who package applications outside of the official repositories?
- Should packages ask whether the user wants to change the default upon install?
The question comes up for me after reading Microsoft Edge is Now Taking Over as Your Default Browser… on Linux, which documents how Edge, as packaged by Microsoft for Debian-based systems, is given a priority of 200 as a browser (with the comment # Good enough to be the default.
). On my Ubuntu 20.04 system, the other priorities for both x-www-browser
and gnome-www-browser
are:
$ update-alternatives --display x-www-browser
x-www-browser - auto mode
link best version is /usr/bin/microsoft-edge-stable
link currently points to /usr/bin/microsoft-edge-stable
link x-www-browser is /usr/bin/x-www-browser
/usr/bin/firefox - priority 40
/usr/bin/google-chrome-beta - priority 150
/usr/bin/microsoft-edge-stable - priority 200
I installed the official Ubuntu chromium-based browser chromium
, which is now using snap
. But it doesn't show up in the alternatives.
I haven't installed google-chrome-stable. Do they also use a priority of 200?
What happens when there is a tie in priority values among alternatives?
Many thanks.
The person or team doing the packaging determines the priorities. In Ubuntu, the stock application defaults of each Ubuntu Flavor are set cooperatively by the team working that flavor. Note that applications (but not default applications) can also be set using metapackages instead of deb control fields. Sigh. It's a rich tapestry.
Users can tell the system which application they want as a default several different ways, and user choice overrides packager priorities. This is not asked during application install (nor should it be!) If their new application misbehaves by stealing default, they can change the default back.
One of the top complaints of users is that the system sometimes asks them questions that they consider irrelevant or simply do not understand. This is why, for example, the Ubuntu installers ask the minimum number of questions to install a working system.
An application that steals default without asking may be considered a bug, and an upstream priority may be changed when the package reaches Ubuntu.
The examples of Edge and Chrome are not distributed by Debian nor Ubuntu, and you can see that the packagers are competing to steal users instead of cooperating. They are being bad neighbors, and perhaps their software might be shunned until they behave. This is not surprising: Organizations that fail to meet the minimum Open Source standards to distribute via Debian/Ubuntu have already demonstrated that they are non-cooperative.
Finally, snap applications are currently generally incompatible with the Debian/Ubuntu update-alternatives system without a bit of haywiring. Reason: update-alternatives is Debian-only, while Snaps are cross-platform. Snapd is Open Source, so anybody who wants to work on making them work together is welcome to pitch in.