How to configure Chrome to open magnet URI's with Deluge?

107,074

Solution 1

The answer is in fact a bug in deluge packaging (or, perhaps deluge is the same & everything else changed around it... depends on your perspective, I guess.) See the forum topic here for the details.

Basically, setting up xdg-open's config via gconf-editor didn't do anything to resolve the issue, since as of Natty the file-open functionality is handled by gvfs-open, which doesn't use gconf settings. Rather, gvfs-open looks at the ".desktop" files bundled with each application to determine what file types can be handled (if not installed, run sudo apt-get install gvfs-bin).

From the forum posting, the /usr/share/applications/deluge.desktop file has a couple issues; it should say Exec=deluge-gtk %U (rather than just "Exec=deluge-gtk") so that the argument is passed to the application. Second, rather than just MimeType=application/x-bittorrent; it should say MimeType=application/x-bittorrent;x-scheme-handler/magnet;.

The update should be coming through soon... Here is the link to the updated desktop file should you want to make the change yourself; just run sudo update-desktop-database and everything just starts working (don't even have to restart chrome/chromium).

Solution 2

For 12.04 up to 16.04

In 12.04 and 13.04, deluge does include x-scheme-handler/magnet=deluge.desktop; in the desktop file. In my case, transmission was still opening magnet links. I had to tell gvfs-open preferring deluge with:

gvfs-mime --set x-scheme-handler/magnet deluge.desktop

For 18.04

gvfs-mime was deprecated and 'gio mime' used instead:

gio mime x-scheme-handler/magnet deluge.desktop

Solution 3

Ubuntu

Recently it is also needed to add the following line to ~/.local/share/applications/mimeapps.list under [Added Associations]

x-scheme-handler/magnet=deluge.desktop;

Kubuntu

On Kubuntu however, you have to create the following file in ~/.kde/share/kde4/services/magnet.protocol

[Protocol]
exec=deluge "%u"
protocol=magnet
input=none
output=none
helper=true
listing=false
reading=false
writing=false
makedir=false
deleting=false

Note: Don't forget to relog after these changes.

Solution 4

I'm using Ubuntu 13.04, and after installing Deluge, I just only need to run this command in order to get Chromium use Deluge to open magnets:

xdg-mime default deluge.desktop x-scheme-handler/magnet

Hope this helps :)

Solution 5

I did all of this and it didn't work.

After having tried everything else I saw, I finally managed to make magnet links open in deluge not only by changing

MimeType=application/x-bittorrent;

to

MimeType=application/x-bittorrent;x-scheme-handler/magnet;

in /usr/share/applications/deluge.desktop, but also by removing

x-scheme-handler/magnet;

from /usr/share/applications/transmission-gtk.desktop before running

sudo update-desktop-database
Share:
107,074

Related videos on Youtube

michael
Author by

michael

Updated on September 18, 2022

Comments

  • michael
    michael almost 2 years

    After upgrading to Ubuntu 11.04 (natty) from 10.10, I can no longer open magnet (torrent) links in Chromium, and set deluge to automatically open and accept the URL.

    (Edit: currently ".torrent" files are not a problem, but magnet URL's, e.g. of the form "magnet:?xt=urn:...", are now the only problem. Not sure if something updated...?)

    Rather, now only transmission will automatically open torrents, magnet links, etc. There doesn't seem to be a way to set deluge to be the default torrent client. (And, there also doesn't seem to be a "default application" setting for BitTorrent client to replace transmission w/ deluge.)

    Notes:

    • I found some old threads on this issue, and only a one or two newer ones. The newer threads seem to suggest xdg-open is to blame. But not many people seem to be running into this problem, so... maybe it's just me?
    • Not using Firefox, so manually setting apps for mime-types or extensions doesn't work (that's not an option in chrome/chromium, AFAIK -- you have to rely on the OS)
    • I uninstalled transmission, and then basically nothing happened when clicking on torrent/magnet links.
    • running from the shell also opens transmission (not deluge): xdg-open "magnet:?xt=urn:bt..&tr=http://tracker.....com/announce".

    My current URL handlers are:

    $ gconftool -a /desktop/gnome/url-handlers/magnet
    command = deluge "%s"
    needs_terminal = false
    enabled = true
    

    The only work-around I have (which does work) is to rename /usr/bin/transmission-gtk{,.bak} and create my own /usr/bin/transmission-gtk:

    $ cat /usr/bin/transmission-gtk
    #!/bin/bash
    deluge "$@"
    

    Anyone else run into this, know of a bug, workaround, or...?

    • michael
      michael about 13 years
      Not a dumb question... The problem is only with magnet url's; ".torrent" files are not a problem. With the magnet url's, there is no file to download. It's like "ftp://..." or "https://..." or file://...". Using nautilus, I can double-click and deluge opens the torrents; using "xdg-open foo.torrent", torrent files are opened correctly with deluge. However using links like "magnet:?..." or even "xdg-open 'magnet:?...'", transmission opens regardless of any gconf settings I make. (I'll see if I can clarify this in the question...)
    • michael
      michael about 13 years
      Actually, originally torrent files were also a problem; but now, surprisingly, torrent files do indeed work. I don't know if something changed (it would have to be xdg-open?) ...or if I changed something to make it start working. So, now I can use torrent files as a work-around. Magnet links are (obviously?) better to use in certain situations, though... would be nice to find out if that is indeed a bug or my (broken) configuration.
    • MestreLion
      MestreLion about 13 years
      Hum, nice clarification. Yes Im aware of what magnet links are.. its similar to apt links. Im just not sure WHO handles them - the OS or the Browser. I mean... do the browser tell passes the magnet request to OS, or does it handle and launches the app itself? In that question it may lie your answer. Meanwhile, Ill check the behaviour of my FF and Chromium
    • michael
      michael about 13 years
      Firefox handle's its own application launchers (or... at least it used to?)... I just googled again and found a recent forum posting with the answer (see below...) Thanks for the comment, it forced me to look into this again. I had just been living with manually opening the magnet links. Kind of a pain.
    • MestreLion
      MestreLion about 13 years
      Ive actually never used magnet links myself. I usually click the .torrent files, and have the browser to silently download and open them. Its always erasier to configure xdg-open with plain files than a "non-standard" url. It can be configured in Nautilus > right-click > Open With (or Properties > Open With Tab)
  • Rinzwind
    Rinzwind about 13 years
    you can add pics in comments ;)
  • MestreLion
    MestreLion about 13 years
    Humm, nice! +1 for that (but it sucks when you have to answer your own question, doesnt it?). Anyway... if Natty requires that .desktop files now have parameters in the Exec statement, wow, basically ALL of my software wont work (I use Mint 10)
  • MestreLion
    MestreLion about 13 years
    It makes no sense for Natty to require parameters in the Exec statement. ITs a huge change that will require rewriting every .desktop for every application. Would be much better to leave the files untouched and tweak gvfs-open call to automatically append any passed parameter to the command in the Exec statement. At least untill ALL applications are fixed.
  • MestreLion
    MestreLion about 13 years
    you can? wow! How? Anyway, that would look awful i think :P
  • michael
    michael about 13 years
    It's interesting that this says that xdg-open is used to open the magnet links.... I can't get that dialog, since my chromium "remembers" my preference for automatically opening magnet urls..! (And, yes, I tried "clear auto-opening settings", even after managing to get it to be un-greyed...) But as part of my "fix" in my answer, I did also install gvfs-open (sudo apt-get install gvfs-bin). Now, if you check the shell script for /usr/bin/xdg-open, the function "open_gnome()" just calls gvfs-open (if it exists), otherwise it calls gnome-open. (What a mess...)
  • Rinzwind
    Rinzwind about 13 years
  • michael
    michael about 13 years
    I should mention that I also installed this to make it work (if you don't have this, you may get different results): sudo apt-get install gvfs-bin
  • MestreLion
    MestreLion about 13 years
    @michael_n: thats why i posted the screenshot.. i figured it would help you to know for sure that Chromium relied on xdg-open (as it should indeed... non-standard URI's must be handled by OS, not Browser)
  • MestreLion
    MestreLion about 13 years
    @michael_n: Ive checked here, in 10.10 xdg_open also chooses between gvfs-open or gnome-open. But I dont think it is a mess... xdg-open is meant to be distro- and destop-agnostic. It even checks for KDE. So it tries to find the best handler given your setup.
  • MestreLion
    MestreLion about 13 years
    @michael_n: the puzzling part is: if you didnt have gvfs-open installed until now, wouldnt your xdg-open try gnome-open? And doesnt gnome-open rely on gconf, which you had correctly configured for magnets? So how come it didnt work before?
  • michael
    michael about 13 years
    @MestreLion - yes, we've come full circle. That was my original question...! :-) ...gconf doesn't seem to make a difference here: changing "/desktop/gnome/url-handlers/magnet" does nothing. Running: gnome-open "magnet:?xt=urn..." still uses /usr/share/applications/deluge.desktop (strace gvfs-open & gnome-open verifies this). Changing deluge.desktop to "Exec transmission-gtk %U", both gvfs-open/gnome-open now open transmission. "What a mess" is perhaps an overstatement; perhaps "What a transition" is more accurate. Probably no need to postulate further here what's going on behind the curtain.
  • michael
    michael about 13 years
    Put more succinctly, /usr/share/applications/transmission-gtk.desktop had an entry for "MimeType=application/x-bittorrent;x-scheme-handler/magnet;"‌​, but deluge.desktop didn't have an entry for MimeType=magnet... Therefore, transmission handled magnet URL's. The gconf settings didn't make a difference. (But, it is cool that pictures can be posted in questions & comments. Something positive came out of this...!)
  • Bombe
    Bombe over 12 years
    If you don’t want to mess with files in /usr you can also copy the .desktop file to .local/share/applications/ and run update-desktop-database .local/share/applications after that.
  • MestreLion
    MestreLion about 12 years
    @Bombe: nice approach. And you probably don't even need to update-desktop-database. Gnome usually has daemons that auto-refresh the menus when new files are dropped in that directory.
  • stolsvik
    stolsvik almost 12 years
    Just hacked Azureus to work. Got the xdg/gvfs bs to kick in Azureus (using all other answers here!): Testing with xdg-open on command line showed that. However, Azureus didn't react. In the azureus.desktop file, it had Exec line with %f. Changed that to %U as mentioned in this answer, and now it works.
  • Umair A.
    Umair A. about 10 years
    worked for me on Ubuntu 12.04
  • Fordi
    Fordi almost 9 years
    Also may need: gvfs-mime --set x-scheme-handler/magnet deluge.desktop Which does the same thing, but also gets the gnome conf database (which may or may not be the same DB as the freedesktop DB)
  • Tico
    Tico about 8 years
    Working for 16.04LTS
  • thethakuri
    thethakuri over 7 years
    worked for me on Ubuntu 16.04
  • uvasal
    uvasal over 5 years
    Working for me in 18.04 with FF
  • ambigus9
    ambigus9 about 5 years
    Thanks. Currently i'm getting the error: Failed to load the information for the manager, Any idea to solve it?