<div dir="ltr"><div>Regarding the standard for the association between MIME types and applications (<a href="https://specifications.freedesktop.org/mime-apps-spec/latest/">https://specifications.freedesktop.org/mime-apps-spec/latest/</a>), xdg-utils provides the tools xdg-mime (for querying a file's MIME type) and xdg-open (for opening applications based on MIME-type).</div><div><br></div><div>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.</div><div><br></div><div>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?</div><div><br></div><div>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: <a href="https://github.com/mbeijen/File-MimeInfo/issues">https://github.com/mbeijen/File-MimeInfo/issues</a></div><div>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</div><div>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.</div><div><br></div><div>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.</div><div><br></div><div>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:</div><div><br></div><div>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).</div><div>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: <a href="https://specifications.freedesktop.org/shared-mime-info-spec/latest/ar01s02.html">https://specifications.freedesktop.org/shared-mime-info-spec/latest/ar01s02.html</a></div><div>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: <a href="https://specifications.freedesktop.org/mime-apps-spec/latest/ar01s02.html">https://specifications.freedesktop.org/mime-apps-spec/latest/ar01s02.html</a></div><div>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</div><div><br></div><div>I am willing to help develop these changes, but only if it is clear that such contributions would actually be welcome and accepted.</div><div><br></div><div>Max</div></div>