Arch Linux

Please read this before reporting a bug:

Do NOT report bugs when a package is just outdated, or it is in Unsupported. Use the 'flag out of date' link on the package page, or the Mailing List.

REPEAT: Do NOT report bugs for outdated packages!

FS#28011 - [xdg-utils] xdg-open seems to ignore the "x-scheme-handler/magnet" handler

Attached to Project: Arch Linux
Opened by Danilo (danilo) - Friday, 20 January 2012, 12:20 GMT
Last edited by Andreas Radke (AndyRTR) - Tuesday, 16 October 2012, 15:32 GMT
Task Type Bug Report
Category Packages: Extra
Status Closed
Assigned To Jan de Groot (JGC)
Andreas Radke (AndyRTR)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 14
Private No


I'm trying to open Deluge when clicking on a magnet:-Link in Chromium. Chromium relies on xdg-open to handle URLs.

If i'm not mistaken, the mime type of a magnet link is "x-scheme-handler/magnet".

I tried to set the mime type handler the following ways:
* `xdg-mime default deluge.desktop application/x-bittorrent x-scheme-handler/magnet`
* By editing `~/.local/share/applications/mimeapps.list` directly (`x-scheme-handler/magnet=deluge.desktop;`)

The mime type has apparently been set correctly.

$ xdg-mime query default "x-scheme-handler/magnet"

But xdg-open does not behave correctly. `xdg-open magnet:?xt=blablabla` opens an empty tab in chromium instead of launching Deluge.

According to this thread, this is a bug in /bin/xdg-open:

Additional info:
* package version: extra/xdg-utils 1.1.0rc1-3
This task depends upon

Closed by  Andreas Radke (AndyRTR)
Tuesday, 16 October 2012, 15:32 GMT
Reason for closing:  Fixed
Additional comments about closing:  snapshot updated to latest git version
Comment by Danilo (danilo) - Friday, 20 January 2012, 12:22 GMT
Oh, as an additional note, I'm using dwm, so there should be no other mime type handler in the way.
Comment by Alex Hyde (tepidpond) - Friday, 09 March 2012, 09:58 GMT
The attached patch against 1.1.0rc1-3's /usr/bin/xdg-open adds proper handling for magnet links. It doesn't step on other URIs, so should be safe to drop into any system.
Comment by John (graysky) - Monday, 26 March 2012, 20:52 GMT
@tepidpond - applied this patch but still no magnet links from chromium :/
Comment by Alex Hyde (tepidpond) - Monday, 26 March 2012, 21:58 GMT
If you're under xfce, Gnome, or KDE, the DE-native tool takes precedence. Without a DE, with a clean Chromium profile, and having just done a full upgrade, it works here. The troubleshooting I can think of is: Does 'xdg-open magnet:?xt=foo' at a console launch your torrent client(note that lacking a correct URI there means a pre-launched client will silently ignore it and appear to have failed)? Does 'xdg-mime query default "x-scheme-handler/magnet"' return the .desktop file of your chosen torrent client?
Comment by John (graysky) - Monday, 26 March 2012, 22:12 GMT
@tep - I'm using lxde.

$ xdg-mime query default "x-scheme-handler/magnet"

Returns nothing. Just a fresh prompt.

$ xdg-open magnet:?xt=foo
Comment by Alex Hyde (tepidpond) - Monday, 26 March 2012, 22:17 GMT
You don't seem to have a mime-handler set for magnet links. Run 'xdg-mime default transmission-gtk.desktop application/x-bittorrent x-scheme-handler/magnet', replacing transmission-gtk.desktop with the desktop file for whichever torrent client you actually want to run.
Comment by John (graysky) - Monday, 26 March 2012, 22:23 GMT
Success! Thanks! Odd thing is that I have to launch deluge manually and then click the link or else clicking a magnet link only loads deluge. Clicking it a 2nd time transfers the link. Anyway, thank you.
Comment by pedram (multiphrenic) - Tuesday, 17 April 2012, 21:55 GMT
Patch works here for chromium and xdg-utils 1.1.0rc1-3. Thank you!
Comment by John Alber (rallyemax) - Friday, 11 May 2012, 23:22 GMT
Here's a slightly revised patch. Tepidpond's patch didn't work for me as written -- the threshold problem was with the variable $1 losing its contents along the way (don't know why, but it might have to do something with subshells being called within the script...bash scripting is definitely not my strong suit). I replaced it with $url (which is defined as $1 earlier in the script, before $1 disappears) and that problem was solved.

A more serious problem was that the open_generic function was not properly calling the open_generic_xdg_mime function. Something bad was happening along the way, but rather than untangle what looked like a somewhat complicated bit of code, I hacked a quick and dirty solution and merely tested for the presence of the "magnet:?xt=" string in the main part of the script, running the open_generic_xdg_mime function if the string was found. That fixed it right up.

My patch is not meant to represent finished work; it's a quick and dirty patch of a patch that works for me and I am sharing it only to shed further light on the underlying bug. All credit to tepidlake, all criticism to me.

It is possible that my particular problems with the original patch are due to the fact that I'm not even running Arch Linux. I'm running Debian 6.0, with Xfce 4.6.2, and on a backported 3.2 kernel from the Debian repos (version 3.2.0-0.bpo.2-amd64). But since I found the solution to this problem on an Arch Linux forum, other people running various distros may also chance upon it -- the underlying bug certainly doesn't appear to be distro-specific.

(I'm using Chrome version 18.0.1025.168, but it shouldn't matter as this bug is not browser-related.)
Comment by Andreas Radke (AndyRTR) - Sunday, 20 May 2012, 09:30 GMT
Please check xdg-utils-1.1.0-0.20120520-any.pkg.tar.xz in testing if this has been solved or file an upstream issue to get your patch included.
Comment by Andreas Radke (AndyRTR) - Tuesday, 29 May 2012, 11:33 GMT
How's xdg-utils 1.1.0-2.20120520 solving a packaging issue now really using latest git scripts?
Comment by Stefan Husmann (stefanhusmann) - Saturday, 02 June 2012, 05:52 GMT
-2 causes problems for me. I use archlinux-xdg-menu for opening a browser with the Arch Linux websites, and it seems like xdg-open cuts off the "http:" from the URL. I am using conkeror as default browser.
Comment by Stefan Husmann (stefanhusmann) - Saturday, 02 June 2012, 16:02 GMT
Forgot to add: downgrading to -0 fixes the issue for me.
Comment by Andreas Radke (AndyRTR) - Wednesday, 06 June 2012, 10:18 GMT
Then there's some regression in new git scripts we generate. Try to locate it and report it upstream.
Comment by Mateusz Loskot (mloskot) - Saturday, 16 June 2012, 12:39 GMT
I think the whole issue may be related to the bug already submitted to

Bug 45859 - xdg-open fails to open a url in a "generic" environment

I have posted about it to the arch-general too:
Comment by Greg (dolby) - Monday, 15 October 2012, 02:39 GMT
The above fd.o bug report has been fixed. Is this still a problem?
Comment by Stefan Husmann (stefanhusmann) - Monday, 15 October 2012, 12:09 GMT
The problem is still there.