[one-liner]: Howto get Firefox 10.x to Launch a BitTorrent Client via a Magnet Link on Linux

Background

If you’ve ever used BitTorrent you’re probably familiar with having to download a .torrent file and then opening it in a BitTorent client such as Vuze (previously known as Azureus). You may not however be that familiar with magnet links, so called trackerless torrents.

The difference? Where a .torrent is a file that includes among other things info about the files you’ll be downloading, a magnet link is just a link that has a hashcode which was generated from the info thats included in the .torrent file.

This excerpt from lifehacker.com explains it a little better:

When you download a .torrent file, you’re essentially downloading a small file that contains information on the larger files you want to download. The torrent file tells your torrent client the names of the files being shared, a URL for the tracker, and more. Your torrent client then calculates a hash code, which is a unique code that only that torrent has-kind of like an ISBN or catalog number. From there, it can use that code to find others uploading those files, so you can download from them.

A magnet link does away with the middleman. A magnet link is essentially a hyperlink containing the hash code for that torrent, which your torrent client can immediately use to start finding people sharing those files. Magnet links don’t require a tracker (since it uses DHT, which you can read more about here), nor does it require you to download a separate file before starting the download, which is convenient.

So now on to the heart of this post. How do you get Firefox 10.x to automatically start the BitTorent client Vuze up when you click on a magnet link? Here’s how.

Solution

Before we get started, a magnet link looks like the following:

1
2
3
magnet:?xt=urn:btih:bd927aef9d957ba4f4402fbbb0b41f9f88f148a4&dn=download+distro+-+linux+\
   fedora&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Ftracker.publicbt.com\
   %3A80&tr=udp%3A%2F%2Ftracker.ccc.de%3A80

Clicking on a magnet link in Firefox will result in this dialog being displayed.

FF Magnet Alert Dialog

FF Magnet Alert Dialog

To get Firefox to identify links that use the handle magnet: you’ll need to add a new preference to Firefox’s about:config. You can get into about:config by typing it in the URL bar.

FF about:config

FF about:config

In the example above, you can see that the preference, network.protocol-handler.expose.magnet, doesn’t exist, so let’s go ahead and add it. Right click where the results are being shown when you searched for handler.expose, select New -> Boolean, and enter the preference name network.protocol-handler.expose.magnet. Next set its value to false.

FF Magnet Alert Dialog
FF about:config
FF about:config Menu
FF Boolean Name Dialog
FF Boolean Value Dialog
FF Example Magnet Link
FF Chooser Dialog
FF Chooser Dialog w/ Azurues/Vuze
Vuze Download Magnet Link

With the magnet handler preference in place, you’ll need to browse to a site with a magnet link on it. Here’s an example:

FF Example Magnet Link

FF Example Magnet Link

After clicking on the magnet link you should see Firefox’s Launch Application Choose Dialog. It’ll be blank, meaning there is no application associated to magnet links, so click the Choose button and navigate to your BitTorrent client. In my example, I’m using Azureus/Vuze, so I navigated to /usr/bin/azureus.

FF Magnet Alert Dialog
FF about:config
FF about:config Menu
FF Boolean Name Dialog
FF Boolean Value Dialog
FF Example Magnet Link
FF Chooser Dialog
FF Chooser Dialog w/ Azurues/Vuze
Vuze Download Magnet Link

Now with an application associated to the magnet handler try clicking on the magnet link again. This time you should see your BitTorrent client startup, if it isn’t already running, and get the magnet link from Firefox, and start downloading the torrent.

Vuze Download Magnet Link

Vuze Download Magnet Link

References

NOTE: For further details regarding my one-liner blog posts, check out my one-liner style guide primer.

This entry was posted in bittorrent, firefox, linux, one-liner, Syndicated, tips & tricks. Bookmark the permalink.

Comments are closed.