Torrent magnet links open new window but not transmission

I've installed Ubuntu and Lubuntu a few times now and some of those times I've had the following problem, which I currently have. When I click a torrent magnet link in Chrome (usually from Pirate bay), instead of opening transmission, the only thing that happens is a new Chrome window opens.

Upon other installations, I've not had this problem; transmission opened just as I'd like.

I've tried using Chrome's extension .torrent to Transmission, but I get the error

unable to contact http ://localhost:9091/transmission/rpc

no response


Solution 1:

You can change the default handler for magnet links by editing the file .local/share/applications/mimeapps.list. Add the association to the two sections in the file like this (leaving other entries in those sections intact):

[Default Applications]
x-scheme-handler/magnet=transmission-gtk.desktop

[Added Associations]
x-scheme-handler/magnet=transmission-gtk.desktop

Log out and log back in for the change to take effect.

Solution 2:

If you want to use torrent to transmission, you have to allow remote access in transmission under preferences/remote.

If you want to open magnet links in transmission by clicking on them, you need to patch the /usr/bin/xdg-open script, here's mine for reference. The added lines are 311 and 490-493.

Solution 3:

If you have installed transmission-gtk then the solution is easy.

gconftool-2 -s /desktop/gnome/url-handlers/magnet/command '/usr/bin/transmission-gtk %s' --type String
gconftool-2 -s /desktop/gnome/url-handlers/magnet/enabled --type Boolean true

The first one adds transmission-gtk as handler for magnet:// links the second enable it.

Since chrome/ium uses xdg-open this is the best method for setting the handlers. You can replace /usr/bin/transmission-gtk for any client you like. This works for almost all flavors of Ubuntu.

You can test this issuing in the terminal xdg-open "magnet:?xt=urn:btih:f41989f9797a88505f9e258d5e5d1354c3731a99" (downloads Ubuntu 13.04 64-bit)


Other solution is using xdg-mime:

xdg-mime default transmission-gtk.desktop application/x-bittorrent
xdg-mime default transmission-gtk.desktop x-scheme-handler/magnet

In case you don't have the mime-types installed use xdg-mime install x-scheme-handler/magnet.