How to tell Chrome what to do with a magnet link?
Solution 1:
Chrome (or Chromium) protocol handling works differently than in Firefox. Firefox basically keeps track of all that itself, which is why you can configure protocol handling (like magnet links) in the Applications part of the Preferences. Chrome, however, relies on xdg-open
.
There are a couple things that you need to do before xdg-open
will handle magnet links properly.
Find the name of the desktop file of the program you want to handle the magnet link. Let's suppose the program is Transmission. It (like usual) has its desktop file in
/usr/share/applications/
and in fact, by perusing the listing of the directory, I find that my version of transmission is actually the gtk version, so its desktop file is calledtransmission-gtk.desktop
.-
It's possible the desktop file is messed up. So you can check that
/usr/share/applications/transmission-gtk.desktop
contains the lines:Exec=transmission-gtk %U [some lines omitted] MimeType=application/x-bittorrent;x-scheme-handler/magnet;
Note the
%U
in the Exec line. It's absolutely necessary. The MimeType line should look as above. -
Now for the essential step to tell
xdg-open
to open magnet links using Transmission. In the terminal, type:xdg-mime default transmission-gtk.desktop x-scheme-handler/magnet
-
(Step not necessary if you use Gnome, KDE, Xfce, or LXDE) Lastly,
xdg-open
assumes you are running one of the standard desktop environments: gnome, kde, xfce and lxde. If you are not,xdg-open
will not work on magnet links. As suggested on the Arch wiki, you can simply modify/usr/bin/xdg-open
. At the end of the file, you'll find a portion that starts with:detectDE if [ x"$DE" = x"" ]; then DE=generic
change
generic
to one ofgnome
,kde
,xfce
, orlxde
. I chosexfce
since I actually have an Xfce session that I've configured and use on occasion.The downside to this approach is that if
xdg-open
gets updates, you'll have to redo this. The Arch wiki suggests another approach that avoids this flaw (but has its own downside).Warning: The choice in the last step is more important than it might seem. Picking
lxde
did not work for me! Inxdg-open
, the helper functionopen_lxde
relies onpcmanfm
(lxde file manager) and something is wrong with either the code inopen_lxde
or perhaps it'spcmanfm
's fault.
Solution 2:
just drag the magnet link into Transmission window and it works fine for me without any tweaks.... I am using a stock build of Lubuntu 12.10 nothing fancy....
Solution 3:
Worked very nice to open magnets from Chrome with qBitorrent in Lubuntu
xdg-mime default qBittorrent.desktop x-scheme-handler/magnet
Solution 4:
In Ubuntu 20.04, run one of the following commands.
Webtorrent
xdg-mime default webtorrent-desktop.desktop x-scheme-handler/magnet
Transmission
xdg-mime default transmission-gtk.desktop x-scheme-handler/magnet
Any other torrent application
X.desktop
file must exist in the /usr/share/applications
directory