Random Bits

Random Bits

  • Home
  • Contact

Fixing uTorrent File Associations in Linux

Running uTorrent under wine works pretty well in Linux. For a quick overview of installation, see this HowTo Ubuntu blog post. One problem with installing under wine is that file associations are not set correctly. This means that double-clicking a .torrent file or opening a .torrent link in your browser won’t automatically start uTorrent. Here’s how to solve that.

First, create a file called utorrent with the following content:

#!/bin/sh

if [ "$1" ]; then
    torrent_file="Z:`echo $1 | sed 's/\//\\\/g'`"
    env WINEPREFIX="/home/avery/.wine" wine \
        "C:\\Program Files\\uTorrent\\uTorrent.exe" "$torrent_file"
else
    env WINEPREFIX="/home/avery/.wine" wine \
        "C:\\Program Files\\uTorrent\\uTorrent.exe"
fi

Replace /home/avery with the path to your home directory. Make sure to make the file executable:

$ chmod +x utorrent

This is the main script that we’ll start uTorrent with. Basically, if given a file path on the command line, it will transform it from a linux path to a wine path. /tmp/sample.torrent will become Z:\tmp\sample.torrent. The sed bit comes from an Ubuntu forums thread.

Next, we need to fix the .desktop file. It should be located at ~/.local/share/applications/wine/µTorrent.desktop and contain something like:

[Desktop Entry]
Name=µTorrent
Exec=env WINEPREFIX="/home/avery/.wine" wine \
    "C:\\Program Files\\uTorrent\\uTorrent.exe"
Type=Application
StartupWMClass=Wine
Icon=6948_utorrent.0

Add the following two lines to the end of the file:

Categories=Network;FileTransfer;P2P
MimeType=application/x-bittorrent

The first line makes uTorrent show up correctly in the GNOME menu system. The next associates uTorrent with the BitTorrent MIME type. Also, change the Exec line to:

Exec=/home/avery/bin/utorrent %f

Obviously, replace the path with wherever you put the utorrent script from above. The .desktop file should now contain:

[Desktop Entry]
Name=µTorrent
Exec=/home/avery/bin/utorrent %f
Type=Application
StartupWMClass=Wine
Icon=6948_utorrent.0
Categories=Network;FileTransfer;P2P
MimeType=application/x-bittorrent

To make uTorrent the default BitTorrent client, edit ~/.local/share/applications/defaults.list:

[Default Applications]
application/x-bittorrent=µTorrent.desktop

This file might already exist, in which case you can just add the second line. Finally, we need to update GNOME’s file associations database:

$ update-desktop-database ~/.local/share/applications

Success:

Iceweasel offers to open a torrent with uTorrent running under wine.

Iceweasel offers to open a torrent with uTorrent running under wine.

Related Posts:

  • RealPlayer on x86_64 (amd64) Debian Linux

    There are a few tricks to getting RealPlayer to work...

  • Making KDE Play Nice on a GNOME Desktop

    I prefer GNOME for the most part, but some KDE...

  • Log iptables Messages to a Separate File with rsyslog

    Learn how to filter iptables log messages to a separate...

  • Monitoring Hard Drive Health on Linux with smartmontools

    S.M.A.R.T. is a system in modern hard drives designed to...

  • Safely Removing External Drives in Linux

    Simply unmounting a filesystem is not the ideal way to...

Sponsored Links:

This entry was posted on Saturday, August 23rd, 2008 at 9:13 AM and is filed under Linux. You can leave a response, or trackback from your own site.

12 Comments on “Fixing uTorrent File Associations in Linux”

Newer Comments »
  1. Atticus says:
    November 24, 2008 at 11:22 PM

    Thank’s, awesome guide. This had been the only thing stopping me from using uTorrent.

    Reply
  2. Gordon says:
    February 3, 2009 at 6:15 PM

    Thanks so much! This works perfectly - and explained extremely well to make it very easy.

    Reply
  3. Jørgen says:
    February 15, 2009 at 4:16 AM

    Thanks for the guide! But somehow this didn’t work for me. µTorrent is the deafault app, but gives error that the path is wrong. I’m pretty sure it’s because the script that changes the paths is not run, because when I edit µTorrent.desktop: Excec=/home/myusername/.. and put in a nonexisting file, I don’t get any error messages and µTorrent opens. Any ideas? I’m using µTorrent 1.8.2 on ubuntu 8.10.

    Reply
  4. Jørgen says:
    February 15, 2009 at 4:17 AM

    Thanks for the guide! But somehow this didn’t work for me. µTorrent is the deafault app, but gives error that the path is wrong, and I’m pretty sure that it’s because the script that changes the paths is not run, because when I edit µTorrent.desktop: Excec=/home/myusername/.. and put in a nonexisting file, I don’t get any error messages and µTorrent opens. Any ideas? I’m using µTorrent 1.8.2 on ubuntu 8.10

    Reply
  5. Jørgen says:
    February 15, 2009 at 4:21 AM

    Sorry, I just got it to work :( The problem was that Open With: had ubuntu.exe instead of ubuntu(default).

    Reply
  6. Lee says:
    March 21, 2009 at 12:56 PM

    I got it to work, but with minor tweaking, I changed this line:
    Exec=/home/avery/bin/utorrent %f
    to:
    Exec=/home/avery/utorrent %f
    and then changed the avery to my username

    Thanks for the help, all the other places I found just wanted me to use a native linux app, NONE OF WHICH worked as well, I never even tried Azaureus since it’s a resource hog.

    Reply
  7. Sérgio Neves says:
    March 21, 2009 at 7:40 PM

    Perfect!

    I search for this. =)

    Tks!

    Reply
  8. _JF says:
    April 23, 2009 at 9:56 PM

    Awesome guide! Thanks!

    Tip: Using global var $HOME on script “utorrent” make it generic, no need for change home path: “${HOME}/.wine”

    Reply
  9. Mark says:
    May 18, 2009 at 4:03 PM

    Just so you know, some quirky things can happen with Ubuntu & WINE. I had to right click on the utorrent script file because of the missing sh extension & tell it to open it with it with bash because it was trying to load the script itself in wine & it’s other open with suggestions were text editors… So I had to use a custom command (bash) to get it to load the script correctly… Just something to watch out for…

    Reply
  10. nikhil says:
    May 21, 2009 at 5:16 AM

    thanks man
    great guide

    Reply
  11. Christian Wilhelmsen says:
    June 9, 2009 at 9:15 AM

    Awsome guide. Rewrote this into norwegian here:

    http://hekta.org/~chriswil/blog/index.php/blog/show/Guide%3A-%C2%B5Torrent-som-standard-torrent-behandler.html

    Worked like a charm

    Reply
  12. Как да асоциираме торент файловете да се отварят с uTorrent под KDE « Блогът на [Deathmaster] says:
    June 19, 2009 at 12:48 PM

    [...] стане това. За целта, съм ползвал информацията от този линк, като там се описва, как да се направи това за [...]

    Reply
Newer Comments »

Leave a Reply

Click here to cancel reply.

  • Topics

    • Personal (1)
    • Technology (13)
      • Linux (11)
      • Web (4)
  • Archives

    • April 2009
    • March 2009
    • January 2009
    • December 2008
    • August 2008
    • July 2008
  • Meta

    • Register
    • Log in
    • Valid XHTML

Feed | Privacy Policy
Copyright © 2008-2009 Random Bits
Powered by Wordpress