xdg-utils does not implement the standard for default applications

Maxwell Anselm silverhammermba at gmail.com
Mon Oct 3 20:09:50 UTC 2016


Regarding the standard for the association between MIME types and
applications (https://specifications.freedesktop.org/mime-apps-spec/latest/),
xdg-utils provides the tools xdg-mime (for querying a file's MIME type) and
xdg-open (for opening applications based on MIME-type).

xdg-mime and xdg-open both attempt to detect the user's desktop environment
and then delegate to some DE-specific tool e.g. gvs-info, kde-open, etc.
That is fine and works well for DE integration. However, in the absence of
a DE, these tools fall back to methods which result in nonstandard behavior.

For example, xdg-mime tries to use mimetype (implemented with Perl's
File::MimeInfo) and if that does not exist, falls back to plain old
/usr/bin/file. Similarly xdg-open tries to use mimeopen (also from Perl)
before anything else. Why is this a problem?

1. While File::MimeInfo may intend to implement the standard, its
developers have no obligation (and seemingly no interest) in doing so well.
mimetype and mimeopen each have several trivially fixable bugs that have
gone unpatched for years: https://github.com/mbeijen/File-MimeInfo/issues
2. /usr/bin/file in particular makes no attempt to follow the XDG standard.
It makes absolutely no sense as a fallback because it will misclassify all
but the most mundane MIME types
3. A lack of a "reference implementation" has led to extreme fragmentation.
Arch Linux alone has six unofficial xdg-open replacements developed by
users who were tired of figuring out why their default application choices
were not being respected by xdg-open.

Let me give you a real example that I experienced (and which sparked my
investigation of this matter): if you do not run a DE, it is entirely
likely that xdg-mime will store its MIME/application associations in a
deprecated location and that xdg-open will completely ignore these
associations (deprecated or otherwise) and open a completely different
application. That simply should not be possible with tools provided by the
organization that has developed the standard.

The freedesktop community would benefit considerably from XDG providing an
actual implementation of the default application standard within xdg-mime
and xdg-open. This would benefit the small but significant group of users
who do not run a well-known DE, this would provide a standard to which
alternative implementations could be compared, and it would place the
ultimate responsibility of standard compliance in the hand of the
standardizing organization (rather than some random CPAN developer). To put
it concretely:

1. xdg-mime and xdg-open should not rely on Perl's File::MimeInfo at all
(this behavior could be enabled with an optional flag if you don't want to
just drop it).
2. In the absence of a detected DE, xdg-mime should be fully capable of
following the shared MIME-info spec to detect a file's MIME type:
https://specifications.freedesktop.org/shared-mime-info-spec/latest/ar01s02.html
3. In the absence of a detected DE, xdg-mime should be fully capable of
creating associations and storing them in the standard, non-deprecated
locations:
https://specifications.freedesktop.org/mime-apps-spec/latest/ar01s02.html
4. In the absence of a detected DE, xdg-open should simply use xdg-mime to
query the MIME type and then use the same standard locations (plus
deprecated, for compatibility) to look up the default application for that
type

I am willing to help develop these changes, but only if it is clear that
such contributions would actually be welcome and accepted.

Max
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/xdg/attachments/20161003/f4bddc5c/attachment.html>


More information about the xdg mailing list