40

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...?

6
  • This may seem a dumb question, but... what if you right-click a .torrent file in nautilus, go for properties, "Open With" tab, and select Deluge? Does it work? Does Deluge at least shows in that list?
    – MestreLion
    May 29, 2011 at 5:09
  • 1
    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
    May 30, 2011 at 8:46
  • 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.
    – michael
    May 30, 2011 at 8:58
  • 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
    – MestreLion
    May 30, 2011 at 9:04
  • 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.
    – michael
    May 30, 2011 at 9:19

16 Answers 16

38

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
3
  • 1
    Working for 16.04LTS
    – trinaldi
    Apr 22, 2016 at 12:40
  • Working for me in 18.04 with FF
    – uvasal
    Nov 5, 2018 at 6:21
  • Thanks. Currently i'm getting the error: Failed to load the information for the manager, Any idea to solve it?
    – ambigus9
    Apr 18, 2019 at 16:03
18

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).

6
  • 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
    May 30, 2011 at 9:22
  • 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
    May 30, 2011 at 9:27
  • 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
    – michael
    May 30, 2011 at 9:38
  • 2
    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.
    – Bombe
    Feb 2, 2012 at 6:11
  • @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.
    – MestreLion
    May 9, 2012 at 3:59
8

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.

2
  • worked for me on Ubuntu 12.04
    – Umair A.
    Jun 7, 2014 at 18:22
  • worked for me on Ubuntu 16.04
    – thethakuri
    Dec 18, 2016 at 7:44
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 :)

1
  • 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)
    – Fordi
    Sep 4, 2015 at 5:43
3

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
2

This was supposed to be a comment, but I needed to upload a pic, so here it goes:

  • In my setup, both FireFox 3.6 and Chromium 11.0 opened Deluge

  • Chromium asked for a confirmation that gives us a hint of whats going on:

enter image description here

This shows that Chromium does NOT launch Deluge directly... it relies on xdg-open for that. Meaning all that must be researched (and fixed) is the OS, not Chromium. Nothing to fix or change in the browser.

This is not an answer, but it will focus your efforts in the right place... what you must fix have nothing to do with the Browser, but the OS.

9
  • you can add pics in comments ;)
    – Rinzwind
    May 30, 2011 at 9:19
  • you can? wow! How? Anyway, that would look awful i think :P
    – MestreLion
    May 30, 2011 at 9:28
  • 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...)
    – michael
    May 30, 2011 at 9:35
  • 1
    see Oli's comment: meta.askubuntu.com/questions/1396/how-do-i-add-images-to-posts ;)
    – Rinzwind
    May 30, 2011 at 9:36
  • @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
    May 30, 2011 at 9:44
2

Download and install this userscript. Now you should be able to quickly add torrent files to Deluge 1.2+ WebUI in Chrome!

Tested on 11.10. For other OS'es you must try out yourself, but I expect it'll work fine on them too.

1

On Ubuntu 10.04 with Deluge and chrome I had to do:

gconftool -t string -s /desktop/gnome/url-handlers/magnet/command "deluge-gtk '%s'"
0
1

I'm on 10.10, tried a bunch of things, this was what worked:

gconftool-2 -t string -s /desktop/gnome/url-handlers/magnet/command "/usr/bin/deluge-gtk %s"
gconftool-2 -s /desktop/gnome/url-handlers/magnet/needs_terminal false -t bool
gconftool-2 -t bool -s /desktop/gnome/url-handlers/magnet/enabled true
1

I don't think this really solves the issue, but at least it works for me (lubuntu 12.04):

  • Hover your mouse over the magnet link until the magnet address is shown at the bottom of your screen.
  • Right-click and select "Copy link address".
  • Open Transmission and under "File" select "Open URL".
  • Paste the URL in the box and start downloading.

By the way, I fear I'm necroposting a little right now, but the above solutions didn't work for me and my answer might be useful to others, since this page was the first result when I searched this issue on Google.

1

In Linux Mint 16 Petra, I had to edit the Transmissions.desktop file in the applications folder, but also in /usr/share/applications/mimeinfo.cache, rather than mimeapps.list

Also, there is another mimeinfo.cache file in /home/[user]/.local/share/applications that can be edited as well, but I assume this would only affect the current user, where as the one in the applications folder affects all users.

Hope this helps out.

EDIT:

Haa, it appears this functionality was built into the latest versions of Deluge. You can go to Edit -> Preferences -> Other -> and associate default magnet links with Deluge.

0

It looks like now the latest releases (ppa) of Deluge did address the points of the selected answer. However that didn't solve my problem with Google Chrome not launching Torrents in my Ubuntu Precise 12.04.

Rather it looked like the xdg-mime used by xdg-open was not set properly. I found here a working solution. i.e.

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

Then a quick check

$ xdg-mime query default x-scheme-handler/magnet
deluge.desktop
$ xdg-mime query default application/x-bittorrent
deluge.desktop

And now it's at last working fine.

0

for me what worked is i went to mimeapps.list file and added tixati as the default magnet handler - its very easy and works fast .

Create desktop shortcut link of the bittorrent client then .

Go to this file --** ( press Ctrl+H ) to show/hide files from view..

/home/.local/share/applications/mimeapps.list

Open the file -mimeapps.list - type this text * x-scheme-handler/magnet=tixati.desktop

click save to the application.

I use tixati for torrent . if u use another bittorrent client -- just replace tixati with other - eg vuze , deluge, . (download tixati from tixati.com )

If you wish to choose transmission then replace tixati with transmission-gtk.desktop

0

Here's @michael_n 's answer in one script :

# rewrite deluge's .desktop file
sudo tee /usr/share/applications/deluge.desktop > /dev/null <<'EOF'
[Desktop Entry]
Version=1.0
Name=Deluge
GenericName=BitTorrent Client
X-GNOME-FullName=Deluge BitTorrent Client
Comment=Download and share files over BitTorrent
TryExec=deluge-gtk
Exec=deluge-gtk %U
Icon=deluge
Terminal=false
Type=Application
Categories=Network;FileTransfer;P2P;GTK
StartupNotify=true
MimeType=application/x-bittorrent;x-scheme-handler/magnet;
EOF

# set association and reload
gvfs-mime --set x-scheme-handler/magnet deluge.desktop
sudo update-desktop-database

Woked for me on ubuntu 15.10 with default installs for chrome and deluge.

-1

My Chrome was using Transmission by default. I wanted to use qBittorrent. On Ubuntu 14.04 I removed Transmission using:

sudo apt-get purge transmission-gtk

Then I 'manually' started qBittorrent and closed it again. The next time I clicked a magnet link I was prompted by Chrome to allow it to call an external application. I allowed this and chrome then fired up qBitorrent.

So it seems that if you don't need to have more than one torrent client on your PC, by removing the others and leaving the one you want, you can force Chrome to use the desired client. A bit of a Chuck Norris solution, but it worked for me.

-2
cd /usr/bin/

sudo sed 's/elif \[ x\"\$GNOME_DESKTOP_SESSION_ID\" \!\= x\"\" \]\; then DE\=gnome\;/elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then DE=gnome;\n    elif [ x"$MATE_DESKTOP_SESSION_ID" != x"" ]; then DE=gnome;/g' -i xdg-*

Worked for me (Mint Mate 16 Petra).

1
  • 1
    Holy sh*t, mate, whoever told you to run this should be added to your "block" list. I stopped reading at cd /usr/bin; sudo sed ... xdg-* ... not every file xdg-* is actually a shell script; some are binary. You need to fix your system if you actually run something like this (you might be ok, since it may not have changed the files at all...) In any case, *_DESKTOP_SESSION_ID is unrelated afaik to the topic at hand, but even so, you just set/unset the env var; you don't sed all scripts in /usr/bin.
    – michael
    Feb 17, 2014 at 5:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .