You are not logged in.

#1 2012-01-17 22:30:35

Jonhoo
Member
Registered: 2009-05-23
Posts: 118

Fixing xdg-open

Hi all fellow archers!

For quite some time, those of us running without a desktop environment have been struggling to cope with xdg-open for handling file opens (especially for Chromium).
Although xdg-open has gotten a bit better over time (it now falls back to mimeopen if it doesn't know what to do).
Unfortunately, this solution is not a "proper" one since mimeopen currently does not work with URIs, only with files.

To get around this, I have made two minor adjustments to my system to make it handle even URIs gracefully.
The first is a hack, the second a (small) patch to xdg-open:

The hack:

ln -s /usr/share/applications/mimeinfo.cache to /usr/share/applications/defaults.list

this will make all applications that register MIME types using MimeType= in their .desktop files the default for their respective MIMEs.
This is required since xdg-mime does not check mimeinfo.cache when looking up applications for mime types, only defaults.list files.
If multiple applications happen to register for the same MIME type, I'm not sure which is chosen as the default, but this should be overridden in ~/.local/share/applications/defaults.list anyway.

The second part, the patch, can be viewed here: http://pastebin.com/EduF8GjC
For those not used to merging patches like this, download the raw .patch file from here: http://pastebin.com/download.php?i=EduF8GjC , and then run

sudo patch /usr/bin/xdg-open <xdg-open_uri_patch.txt

Note that you shouldn't normally just do what strangers like me tell you to, so have a look through the .patch file before patching /usr/bin/xdg-open to make sure I haven't done something naughty.
There are also unreleased patches for this upstream here and here if you'd prefer using those, but they may not patch nicely against the current Arch version.

Essentially, whenever a URI is being opened with the internal, generic opener, xdg-mime is queried for the default application for "x-scheme-handler/$scheme" where $scheme is the scheme part of the URI.
That application is then started with the full URI the path to open.

Now sit back and enjoy Chromium opening all your files correctly, even magnet:, mailto: and spotify: links (if you've got a client for each installed of course).

Jon

PS: The patch has also been submitted to the Portland/XdgUtils team as bug #44873
EDIT: Turns out this has already been patched after a similar bugreport, just not released, in these commits. The patch is still needed until a release with these changes comes though. Feel free to use the upstream patches instead if you want.

Last edited by Jonhoo (2012-01-17 22:49:21)

Offline

Board footer

Powered by FluxBB