Tuesday, March 6, 2007

rtorrent & dtach

My search for a new torrent client has come to a close with the winner being rtorrent.
It provides an ncurses interfaces and encryption! Perfect. No more having to deal with a resource hungry GUI. Unfortunately the port for rtorrent didn't include a default rc file or create on upon first run. So, I downloaded the rc file from the website, tweaked it to my liking and off we go.

During my search I stumbled upon people suggesting the use of "GNU screen" to be able to allow rtorrent to run in the background, yet be able to attach and detach from the application at will and from remote locations. Cool.

However, I also saw a lot of posts about GNU screen being bloated, slow and awkward to use - and most suggested dtach instead: a fork of GNU screen that has been trimmed down.

So after installing rtorrent and dtach and reading the man pages I gave it a go:

dtach -A /tmp/rtorrent.dtach rtorrent

The program starts....I add a torrent file (the backspace key)....and sure enough it runs like a charm. ctrl-\ and I've detached. dtach -a /tmp/rtorrent.dtach and I'm attached again.

dtach will definitely come in handy when remotely installing ports/packages or building something that will take longer than I can keep a remote session open. Sure a build can be done in the background, but portupgrade requires an attached terminal because it may ask questions of the user.

2 comments:

hoogs said...

I tried dtach but it has a bug that somehow remaps the arrow keys in rtorrent. This is not cool because rtorrent is all about the arrow keys. I switched to screen, it is better. If I only have one screen session (usual), I don't have to enter the screen pid to reattach, which is handy (i.e. "screen -r" is sufficient).

Андрей Воропаев said...

I don't know about exact reasons, why this happens. But I've found couple work-arounds. First is to use 'tput smkx' before attaching to rtorrent session, and 'tput rmkx' after detachment. Second one is to do 'TERM=linux dtach -a ...'. I haven't tried second one yet, since first one works for me.