Labels

bittorrent (1) chromium (1) dvb (1) dvb-t (1) fedora (1) fm (1) gqrx (1) howto (1) idle (1) ireland (1) linux (3) lubuntu (1) openbsd (1) ps1 (1) radio (1) rtl-sdr (1) sdr (1) shell (1) tips (1) tuning (1) tv (1) unix (1) vlc (1)

Sunday, July 22, 2012

(Lubuntu 12.04) How to teach Chromium to open BitTorrent magnet links

Here's the solution for the impatient:

  1. Create a bin directory in your home directory.
  2. Inside bin, create a file called xdg-open with the following content:
    #!/bin/sh # A workaround to make BitTorrent magnet links work. # # If a magnet link is given as an argument -- open it # with Transmission, otherwise execute the real xdg-open # passing all arguments through. case "$1" in magnet*) transmission-gtk "$1" > /dev/null & ;; *) exec /usr/bin/xdg-open "$@" ;; esac
  3. Change the file's permissions so that it's executable.
  4. Log out and log back in so that the changes take effect.
  5. The magnet links should now open in Transmission when you click them.

After installing the latest Lubuntu 12.04, I noticed that Chromium is unable to open BitTorrent magnet links. Chromium executes the xdg-open command, giving it the magnet link as an argument, but xdg-open doesn't know how to open the magnet link either.

After googling for a bit I came across two solutions but neither of them worked for me.

http://www.foresightlinux.se/make-chromium-to-open-magnet-links/
I didn't like this approach because it involves changing the xdg-open script, which is naturally a part of some package. I have a feeling that this might cause problems with the package manager because the checksum of the file will change. And whenever the script will be updated, you would have to make the modifications again, because the file would be overwritten.

http://askubuntu.com/a/133693
This one simple didn't work.

So my solution is to provide a script which pretends to be xdg-open. If it receives a magnet link as an argument, it opens it with Transmission, otherwise it just runs the real xdg-open, passing all the arguments through. Chromium will pick up this fake xdg-open over the real one because the $HOME/bin directory will come earlier than /usr/bin in the PATH environment variable.

1 comment: