One of the applications I couldn’t let go of when I switched from Windows to Ubuntu was uTorrent. Unfortunately, as you need to run uTorrent using Wine, there is no direct way to automatically launch uTorrent when you click a .torrent link in your browser. Up until now I had a workaround – I created a separate folder in which I saved the torrent files and told uTorrent to watch it for any new files. It works great, and the torrents appear pretty much instantly in the download list. This obviously only works as long the app is running in the first place.
Now I just came across this post on the Ubuntu forums. All you need is a small script which you get Firefox (or any other browser you’re using) to launch when a .torrent link is clicked. Do the following:
From the terminal create a new file for the script:
sudo gedit /usr/bin/utorrent
Now paste the following into it:
#!/bin/sh
cd ~/.wine/drive_c/Program\ Files/utorrent
if [ "$1" != "" ]; then
var="`echo $1 | sed 's/\//\\\/g'`"
var="Z:${var}"
wine utorrent.exe "$var"
else
wine utorrent.exe
fi
Make sure the path to the uTorrent folder is correct, then save.
Set the file permissions:
sudo chmod a+x /usr/bin/utorrent
(Update: if you are having problems with the above script then try Adam’s solution down in the comments)
All you need now is to open your browser’s Preferences and tell it to launch your new script when you click a torrent file. Works like a charm.
Possibly related posts:





June 15th, 2007 on 8:58 am
beautiful
September 28th, 2007 on 9:46 pm
Wow this is great! I’ve been working at this for a while now! I feel like i’m almost there, but there’s one problem. I followed your steps, but whenever I launch a .torrent file i get the error, “Unable to load ‘Z’: Access Denied!”
September 30th, 2007 on 3:10 pm
Sorry Emory, not sure what’s wrong there.
May 18th, 2008 on 7:53 pm
Hey i found it easier to just have utorrent add torrent from url and copy paste it in. I only use isohunt for torrents though so i havent tried it on others.
May 18th, 2008 on 8:29 pm
@Bennett
Seriously. I don’t think it could get any easier than the above
It works with all the torrent sites I’ve come across. The only thing that might be different from site to site is that on most the torrent is automatically added to uTorrent. On a few sites it pops up the dialog asking what to do with the file, i.e. open with or save.
August 16th, 2008 on 9:31 am
I had the same problem “Unable to load ‘Z’: Access Denied!” error message
I found a few problems in your script.
1. If I copy and paste the script, the single quote characters you have used are not proper single quote characters (they look slanty) and break bash/sed. I simply replaced them with proper single quote characters.
2. The script does not support whitespace in the torrent file name. I simply replaced $1 with $* to add this support
3. The script does not seem to work if the torrent file was saved by the web browser into the /tmp/ directory, because bash/sed is translating the /t in the word /tmp to a literal tab character (/t) which then breaks uTorrent.
I hacked the script till I got it to behave correctly for me.
#!/bin/sh
cd ~/.wine/drive_c/Program\ Files/uTorrent
if [ "$1" != "" ]; then
var=`echo Z:$* | sed ’s/\//\\\\/g’ 2>/dev/null > /tmp/utorrent_file`
var=$(cat /tmp/utorrent_file | sed ’s/\\/\\\\/g’)
wine uTorrent.exe “$var”
else
wine uTorrent.exe
fi
Regards,
-adam
August 16th, 2008 on 11:39 am
Thanks for the update, Adam.
I’m going to leave the script in the OP as it is, I never had any problems with any torrents I downloaded. But I will add a note referring to your solution for other people who run into problems.
October 24th, 2008 on 12:33 pm
Note that this website apparently breaks formatting. You have to change all quotes manually, both single and double, if you copy and paste the scripts. That goes for the original post as well as Adam’s.
October 25th, 2008 on 12:51 am
@Johan:
I just copied and pasted both the original script and Adam’s into gedit and both look alright. I didn’t save and try them out as I don’t use uTorrent anymore (I switched to Deluge since Ubuntu 8.04 was released).
Always double-check scripts you copy from websites anyway. A lot of sites do break the formatting.
November 30th, 2008 on 1:14 pm
Great post, i had uTorrent running under wine quite fine, thanks