Friday 13 January 2012

Change magnet links association in linux (Ubuntu)

The Pirate Bay soon will stop serving torrents and a while back I wrote about associating manget links with any torrent client, but that tutorial doesn't work anymore with the newest Ubuntu releases. So, now I'm going to show you how to change the file association so that it will work with any version of Ubuntu or many linux distrobutions.

I'm going to write this tip using ktorrent as it is my favorite torrent client, but if you are using a different client it shouldn't be to hard to change the step to suite your needs. Lets start.

First of all we are going to make sure that you torrent client associates magnet links.

We are going to edit the "*.desktop". They should be under:


in my case because is a kde application it would be under:


There should be the file we need to open and edit but instead of clicking at it. Open gedit and direct it to that location. You should see a bunch of "*.desktop" files. In my case I will open:


In the file you look for the MymeType. You should see something like this:


Now, we will add the magnet association to the file by adding "x-scheme-handler/magnet;" at the end of the MymeType like so:


Save and close the file. Now we are going to make the system to call the magnet handler we just created by changing/adding the file association. You can change it for each user or the system in general.

The file associations for each user are stored in:

sudo gedit ~/.local/share/applications/mimeapps.list

The system-wide file associations are stored in:

sudo gedit /usr/share/applications/defaults.list

Now look for "x-scheme-handler/magnet", it may not be there but just make sure not to enter duplicates. Now add/edit this line for the handler to call the same "*.desktop" file we edited before. Because in my case the "ktorrent.desktop" file was under the kde4 folder I have to add it, but if you file was on the root of the "/usr/share/applications" there is no need to add anything. In my case it would look like so:


Save and close the file. Now, you should be able to open Magnet links with you favorite torrent client.