Difference between revisions of "Ktorrent"

From ArchWiki
Jump to: navigation, search
(Created page with "Category:Internet Applications [http://ktorrent.org/ Ktorrent] is a the BitTorrent client for KDE. ==Installation== Install {{pkg|ktorrent}} package. ==Script to manag...")
 
m (Spaces.)
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
[[Category:Internet Applications]]
 
[[Category:Internet Applications]]
 
 
[http://ktorrent.org/ Ktorrent] is a the BitTorrent client for KDE.
 
[http://ktorrent.org/ Ktorrent] is a the BitTorrent client for KDE.
  
==Installation==
+
== Installation ==
  
Install {{pkg|ktorrent}} package.
+
Install {{Pkg|ktorrent}} package.
  
==Script to manage it in command line==
+
== Script to manage it in command line ==
  
 
Since Ktorrent is a GUI only application, fortunately has a DBUS interface, so you can use scripts to manage it in command line (i.e. from SSH).
 
Since Ktorrent is a GUI only application, fortunately has a DBUS interface, so you can use scripts to manage it in command line (i.e. from SSH).
Line 13: Line 12:
 
Here is the script that I use. I have found it on internet on an OpenSuse forum (made by amaurea) and I integrated new commands to set max upload/download speed and to suspend/resume ktorrent activity.
 
Here is the script that I use. I have found it on internet on an OpenSuse forum (made by amaurea) and I integrated new commands to set max upload/download speed and to suspend/resume ktorrent activity.
  
#!/bin/bash
+
{{hc|/usr/local/bin/kt|<nowiki>
# Public domain script by amaurea/amaur on IRC (freenode for example).
+
#!/usr/bin/env bash
# gary example
+
#
# qdbus org.ktorrent.ktorrent /core startAll
+
# Public domain script by amaurea/amaur on IRC (freenode for example).
+
#  Modified by trapanator to support download/upload rate setting and
+
#                          to suspend/resume ktorrent network activity
case $1 in
+
#
        help)
+
# gary example
                echo "kt: A simple console interface for ktorrent.
+
#   qdbus org.ktorrent.ktorrent /core startAll
Usage: In the following \"id\" indicates either a torrent hash or index.
+
 
        [] indicates optional arguments.
+
 
+
case $1 in
        kt start [id]: If ktorrent is not running, start it. Otherwise,
+
        help)
                      if id is given, start that torrent, otherwise start
+
                echo "kt: A simple console interface for ktorrent.
                      all torrents.
+
Usage: In the following \"id\" indicates either a torrent hash or index.
        kt quit: Quit ktorrent.
+
      [] indicates optional arguments.
        kt load url: Load the torrent given by url. Note that the torrent must
+
 
                    be manually startet afterwards.
+
      kt start [id]: If ktorrent is not running, start it. Otherwise,
        kt ls: Print a list of all torrents, of the format: index hash name.
+
                      if id is given, start that torrent, otherwise start
        kt info [id]: Print more detailed info about the selected (or all)
+
                      all torrents.
                      torrent(s).
+
      kt quit: Quit ktorrent.
        kt stop [id]: Stop the torrent given by id, or all if id is missing.
+
      kt load url: Load the torrent given by url. Note that the torrent must
        kt name [id]: Like ls, but names only.
+
                    be manually startet afterwards.
        kt remove id: Remove the torrent given by id (but not the actual files).
+
      kt ls: Print a list of all torrents, of the format: index hash name.
        kt clear: Remove all torrents.
+
      kt info [id]: Print more detailed info about the selected (or all)
        kt files [id]: List information about the files of the selected torrent.
+
                    torrent(s).
        kt pri [id] [priority]: Give the selected torrent the given priority.
+
      kt stop [id]: Stop the torrent given by id, or all if id is missing.
        kt pri [id] [file index] [priority]: Set the priority of the given file.
+
      kt name [id]: Like ls, but names only.
        kt pri [id] equal: Give all files of the torrent the same priority.
+
      kt remove id: Remove the torrent given by id (but not the actual files).
        kt pri [id] first: Download the first files in the torrent first.
+
      kt clear: Remove all torrents.
        kt stu [n] set upload rate to n.
+
      kt files [id]: List information about the files of the selected torrent.
        kt sdu [n] set download rate to n.
+
      kt pri [id] [priority]: Give the selected torrent the given priority.
        kt suspend  suspend all torrents.
+
      kt pri [id] [file index] [priority]: Set the priority of the given file.
        kt resume    resume all torrents."
+
      kt pri [id] equal: Give all files of the torrent the same priority.
        exit ;;
+
      kt pri [id] first: Download the first files in the torrent first.
esac
+
      kt stu [n] set upload rate to n.
pid=$(pidof ktorrent)
+
      kt sdu [n] set download rate to n.
if [ ! $pid ]; then
+
      kt suspend  suspend all torrents.
        case "$1" in
+
      kt resume    resume all torrents."
                start)
+
      exit ;;
                        ktorrent --display :0.0 ;;
+
esac
                *)
+
pid=$(pidof ktorrent)
                        echo "ktorrent is not running!" ;;
+
if [ ! $pid ]; then
        esac
+
    case "$1" in
        exit
+
        start)
fi
+
            ktorrent --display :0.0 ;;
eval "export $(cat /proc/$(pidof ktorrent)/environ | perl -pne 's/\0/\n/g' | fgrep -a DBUS_SESSION_BUS_ADDRESS)"
+
        *)
loc="org.ktorrent.ktorrent"
+
            echo "ktorrent is not running!" ;;
cmd="qdbus $loc"
+
    esac
case "$1" in
+
    exit
stu)
+
fi
if [ "$2" ]; then
+
eval "export $(perl -pne 's/\0/\n/g' /proc/$(pidof ktorrent)/environ | fgrep -a DBUS_SESSION_BUS_ADDRESS)"
qdbus org.ktorrent.ktorrent /settings setMaxUploadRate $2
+
loc="org.ktorrent.ktorrent"
qdbus org.ktorrent.ktorrent /settings apply
+
cmd="qdbus $loc"
else echo "upload rate missing!" ;  fi ;;
+
case "$1" in
std)
+
stu)
if [ "$2" ]; then
+
  if [ "$2" ]; then
qdbus org.ktorrent.ktorrent /settings setMaxDownloadRate $2
+
  qdbus org.ktorrent.ktorrent /settings setMaxUploadRate $2
qdbus org.ktorrent.ktorrent /settings apply
+
  qdbus org.ktorrent.ktorrent /settings apply
else echo "download rate missing!" ;  fi ;;
+
  else echo "upload rate missing!" ;  fi ;;
suspend)
+
std)
qdbus org.ktorrent.ktorrent /core org.ktorrent.core.setSuspended true ;;
+
  if [ "$2" ]; then
resume)
+
  qdbus org.ktorrent.ktorrent /settings setMaxDownloadRate $2
qdbus org.ktorrent.ktorrent /core org.ktorrent.core.setSuspended false ;;
+
  qdbus org.ktorrent.ktorrent /settings apply
        load)
+
  else echo "download rate missing!" ;  fi ;;
                res=`$cmd /core loadSilently "$2" 1` ;;
+
suspend)
        list|ls)
+
  qdbus org.ktorrent.ktorrent /core org.ktorrent.core.setSuspended true ;;
                torrents=`$cmd /core torrents`
+
resume)
                i=0
+
  qdbus org.ktorrent.ktorrent /core org.ktorrent.core.setSuspended false ;;
                for torrent in $torrents; do
+
    load)
                        name=`$cmd /torrent/$torrent name`
+
        res=$($cmd /core loadSilently "$2" 1) ;;
                        printf "%d %s %s\n" $i $torrent "$name"
+
    list|ls)
                        i=$(($i+1))
+
        torrents=$($cmd /core torrents)
                done ;;
+
        i=0
        info)
+
        for torrent in $torrents; do
                if [ "$2" ]; then
+
            name=$($cmd /torrent/$torrent name)
                        if (( ${#2} < 4 )); then
+
            printf "%d %s %s\n" $i $torrent "$name"
                                torrents=(`$cmd /core torrents`)
+
            i=$(($i+1))
                                torrents=${torrents[$2]}
+
        done ;;
                        else torrents=$2; fi
+
    info)
                else torrents=`$cmd /core torrents`; fi
+
        if [ "$2" ]; then
                i=0
+
            if (( ${#2} < 4 )); then
                for torrent in $torrents; do
+
                torrents=($($cmd /core torrents))
                        name=`$cmd /torrent/$torrent name`
+
                torrents=${torrents[$2]}
                        size=`$cmd /torrent/$torrent totalSize`
+
            else torrents=$2; fi
                        dsize=`$cmd /torrent/$torrent bytesToDownload`
+
        else torrents=$($cmd /core torrents); fi
                        prog=`$cmd /torrent/$torrent bytesDownloaded`
+
        i=0
                        speed=`$cmd /torrent/$torrent downloadSpeed`
+
        for torrent in $torrents; do
                        seed=`$cmd /torrent/$torrent seedersConnected`
+
            name=$($cmd /torrent/$torrent name)
                        leech=`$cmd /torrent/$torrent leechersConnected`
+
            size=$($cmd /torrent/$torrent totalSize)
                        priority=`$cmd /torrent/$torrent priority`
+
            dsize=$($cmd /torrent/$torrent bytesToDownload)
                        sl=`printf "[%d|%d]" $seed $leech`
+
            prog=$($cmd /torrent/$torrent bytesDownloaded)
                        pri=`printf "(%d)" $priority`
+
            speed=$($cmd /torrent/$torrent downloadSpeed)
                        printf "%3.0lf%% of %11d %4.0lf kb/s %8s %4s %s\n" $((100*$prog/$dsize)) $dsize $(($speed/1000)) $sl $pri "$name"
+
            seed=$($cmd /torrent/$torrent seedersConnected)
                        i=$(($i+1))
+
            leech=$($cmd /torrent/$torrent leechersConnected)
                done ;;
+
            priority=$($cmd /torrent/$torrent priority)
        name|stop|start|remove|files)
+
            sl=$(printf "[%d|%d]" $seed $leech)
                if (( ${#2} < 4 )); then
+
            pri=$(printf "(%d)" $priority)
                        torrents=(`$cmd /core torrents`)
+
            printf "%3.0lf%% of %11d %4.0lf kb/s %8s %4s %s\n" $((100*$prog/$dsize)) $dsize $(($speed/1000)) $sl $pri "$name"
                        torrent=${torrents[$2]}
+
            i=$(($i+1))
                else torrent=$2; fi
+
        done ;;
                case "$1" in
+
    name|stop|start|remove|files)
                        name)
+
        if (( ${#2} < 4 )); then
                                $cmd /torrent/$torrent name ;;
+
            torrents=($($cmd /core torrents))
                        start)
+
            torrent=${torrents[$2]}
                                if [ "$2" ]; then res=`$cmd /core start $torrent`
+
        else torrent=$2; fi
                                else res=`$cmd /core startAll`; fi;;
+
        case "$1" in
                        stop)
+
            name)
                                if [ "$2" ]; then res=`$cmd /core stop $torrent`
+
                $cmd /torrent/$torrent name ;;
                                else res=`$cmd /core stopAll`; fi;;
+
            start)
                        remove)
+
                if [ "$2" ]; then res=$($cmd /core start $torrent)
                                # qdbus boolean bug workaround: use dbus-send instead
+
                else res=$($cmd /core startAll); fi;;
                                res=`dbus-send --type=method_call --dest=$loc /core org.ktorrent.core.remove string:"$torrent" boolean:false` ;;
+
            stop)
                        files)
+
                if [ "$2" ]; then res=$($cmd /core stop $torrent)
                                n=`$cmd /torrent/$torrent numFiles`
+
                else res=$($cmd /core stopAll); fi;;
                                for (( i=0; i < $n; i++ )); do
+
            remove)
                                        path=`$cmd /torrent/$torrent filePath $i`
+
                # qdbus boolean bug workaround: use dbus-send instead
                                        pct=`$cmd /torrent/$torrent filePercentage $i`
+
                res=$(dbus-send --type=method_call --dest=$loc /core org.ktorrent.core.remove string:"$torrent" boolean:false) ;;
                                        size=`$cmd /torrent/$torrent fileSize $i`
+
            files)
                                        priority=`$cmd /torrent/$torrent filePriority $i`
+
                n=$($cmd /torrent/$torrent numFiles)
                                        printf "%d %3.0lf%% of %11d [%d] %s\n" $i $pct $size $priority "$path"
+
                for (( i=0; i < $n; i++ )); do
                                done ;;
+
                    path=$($cmd /torrent/$torrent filePath $i)
                esac ;;
+
                    pct=$($cmd /torrent/$torrent filePercentage $i)
        pri|priority|prioritize)
+
                    size=$($cmd /torrent/$torrent fileSize $i)
                if [ $3 ]; then
+
                    priority=$($cmd /torrent/$torrent filePriority $i)
                        if (( ${#2} < 4 )); then
+
                    printf "%d %3.0lf%% of %11d [%d] %s\n" $i $pct $size $priority "$path"
                                torrents=(`$cmd /core torrents`)
+
                done ;;
                                torrent=${torrents[$2]}
+
        esac ;;
                        else torrent=$2; fi
+
    pri|priority|prioritize)
                        if [ ! $torrent ]; then exit; fi
+
        if [ $3 ]; then
                        n=`$cmd /torrent/$torrent numFiles`
+
            if (( ${#2} < 4 )); then
                        if [ $4 ]; then
+
                torrents=($($cmd /core torrents))
                                res=`$cmd /torrent/$torrent setFilePriority $3 $4`
+
                torrent=${torrents[$2]}
                        else
+
            else torrent=$2; fi
                                case $3 in
+
            if [ ! $torrent ]; then exit; fi
                                        equal|equalize)
+
            n=$($cmd /torrent/$torrent numFiles)
                                                for (( i=0; i < $n; i++ )); do
+
            if [ $4 ]; then
                                                        res=`$cmd /torrent/$torrent setFilePriority $i 40`
+
                res=$($cmd /torrent/$torrent setFilePriority $3 $4)
                                                done ;;
+
            else
                                        inc|increasing)
+
                case $3 in
                                                for (( i=0; i < $n; i++ )); do
+
                    equal|equalize)
                                                        pri=`printf "%2.0lf" $(((4*$i/$n+3)*10))`
+
                        for (( i=0; i < $n; i++ )); do
                                                        res=`$cmd /torrent/$torrent setFilePriority $i $pri`
+
                            res=$($cmd /torrent/$torrent setFilePriority $i 40)
                                                done ;;
+
                        done ;;
                                        dec|decreasing)
+
                    inc|increasing)
                                                for (( i=0; i < $n; i++ )); do
+
                        for (( i=0; i < $n; i++ )); do
                                                        pri=`printf "%2.0lf" $(((4*($n-$i-1)/$n+3)*10))`
+
                            pri=$(printf "%2.0lf" $(((4*$i/$n+3)*10)))
                                                        res=`$cmd /torrent/$torrent setFilePriority $i $pri`
+
                            res=$($cmd /torrent/$torrent setFilePriority $i $pri)
                                                done ;;
+
                        done ;;
                                        first)
+
                    dec|decreasing)
                                                m=$(($n < 3 ? $n : 3))
+
                        for (( i=0; i < $n; i++ )); do
                                                for (( i=0; i < $m; i++ )); do
+
                            pri=$(printf "%2.0lf" $(((4*($n-$i-1)/$n+3)*10)))
                                                        res=`$cmd /torrent/$torrent setFilePriority $i $(((6-$i)*10))`
+
                            res=$($cmd /torrent/$torrent setFilePriority $i $pri)
                                                done
+
                        done ;;
                                                for (( i=3; i < $n; i++ )) do
+
                    first)
                                                        res=`$cmd /torrent/$torrent setFilePriority $i 30`
+
                        m=$(($n < 3 ? $n : 3))
                                                done ;;
+
                        for (( i=0; i < $m; i++ )); do
                                        *)
+
                            res=$($cmd /torrent/$torrent setFilePriority $i $(((6-$i)*10)))
                                                res=`$cmd /torrent/$torrent setPriority $3` ;;
+
                        done
                                esac
+
                        for (( i=3; i < $n; i++ )) do
                        fi
+
                            res=$($cmd /torrent/$torrent setFilePriority $i 30)
                else echo Too few arguments!; fi ;;
+
                        done ;;
        clear)
+
                    *)
                torrents=`$cmd /core torrents`
+
                        res=$($cmd /torrent/$torrent setPriority $3) ;;
                for torrent in $torrents; do
+
                esac
                        res=`dbus-send --type=method_call --dest=$loc /core org.ktorrent.core.remove string:"$torrent" boolean:false`
+
            fi
                done ;;
+
        else echo Too few arguments!; fi ;;
        quit)
+
    clear)
                res=`$cmd /MainApplication quit` ;;
+
        torrents=$($cmd /core torrents)
        *)
+
        for torrent in $torrents; do
                echo "Unrecognized command: '$1'" ;;
+
            res=$(dbus-send --type=method_call --dest=$loc /core org.ktorrent.core.remove string:"$torrent" boolean:false)
esac
+
        done ;;
 +
    quit)
 +
        res=$($cmd /MainApplication quit) ;;
 +
    *)
 +
        echo "Unrecognized command: '$1'" ;;
 +
esac
 +
</nowiki>}}

Revision as of 21:37, 23 February 2014

Ktorrent is a the BitTorrent client for KDE.

Installation

Install ktorrent package.

Script to manage it in command line

Since Ktorrent is a GUI only application, fortunately has a DBUS interface, so you can use scripts to manage it in command line (i.e. from SSH).

Here is the script that I use. I have found it on internet on an OpenSuse forum (made by amaurea) and I integrated new commands to set max upload/download speed and to suspend/resume ktorrent activity.

/usr/local/bin/kt
#!/usr/bin/env bash
#
# Public domain script by amaurea/amaur on IRC (freenode for example).
#   Modified by trapanator to support download/upload rate setting and
#                          to suspend/resume ktorrent network activity
#
# gary example
#   qdbus org.ktorrent.ktorrent /core startAll


case $1 in
        help)
                echo "kt: A simple console interface for ktorrent.
Usage: In the following \"id\" indicates either a torrent hash or index.
       [] indicates optional arguments.

       kt start [id]: If ktorrent is not running, start it. Otherwise,
                      if id is given, start that torrent, otherwise start
                      all torrents.
       kt quit: Quit ktorrent.
       kt load url: Load the torrent given by url. Note that the torrent must
                    be manually startet afterwards.
       kt ls: Print a list of all torrents, of the format: index hash name.
       kt info [id]: Print more detailed info about the selected (or all)
                     torrent(s).
       kt stop [id]: Stop the torrent given by id, or all if id is missing.
       kt name [id]: Like ls, but names only.
       kt remove id: Remove the torrent given by id (but not the actual files).
       kt clear: Remove all torrents.
       kt files [id]: List information about the files of the selected torrent.
       kt pri [id] [priority]: Give the selected torrent the given priority.
       kt pri [id] [file index] [priority]: Set the priority of the given file.
       kt pri [id] equal: Give all files of the torrent the same priority.
       kt pri [id] first: Download the first files in the torrent first.
       kt stu [n] set upload rate to n.
       kt sdu [n] set download rate to n.
       kt suspend   suspend all torrents.
       kt resume    resume all torrents."
       exit ;;
esac
pid=$(pidof ktorrent)
if [ ! $pid ]; then
    case "$1" in
        start)
            ktorrent --display :0.0 ;;
        *)
            echo "ktorrent is not running!" ;;
    esac
    exit
fi
eval "export $(perl -pne 's/\0/\n/g' /proc/$(pidof ktorrent)/environ | fgrep -a DBUS_SESSION_BUS_ADDRESS)"
loc="org.ktorrent.ktorrent"
cmd="qdbus $loc"
case "$1" in
 stu)
  if [ "$2" ]; then
   qdbus org.ktorrent.ktorrent /settings setMaxUploadRate $2
   qdbus org.ktorrent.ktorrent /settings apply
  else echo "upload rate missing!" ;  fi ;;
 std)
  if [ "$2" ]; then
   qdbus org.ktorrent.ktorrent /settings setMaxDownloadRate $2
   qdbus org.ktorrent.ktorrent /settings apply
  else echo "download rate missing!" ;  fi ;;
 suspend)
  qdbus org.ktorrent.ktorrent /core org.ktorrent.core.setSuspended true ;;
 resume)
  qdbus org.ktorrent.ktorrent /core org.ktorrent.core.setSuspended false ;;
    load)
        res=$($cmd /core loadSilently "$2" 1) ;;
    list|ls)
        torrents=$($cmd /core torrents)
        i=0
        for torrent in $torrents; do
            name=$($cmd /torrent/$torrent name)
            printf "%d %s %s\n" $i $torrent "$name"
            i=$(($i+1))
        done ;;
    info)
        if [ "$2" ]; then
            if (( ${#2} < 4 )); then
                torrents=($($cmd /core torrents))
                torrents=${torrents[$2]}
            else torrents=$2; fi
        else torrents=$($cmd /core torrents); fi
        i=0
        for torrent in $torrents; do
            name=$($cmd /torrent/$torrent name)
            size=$($cmd /torrent/$torrent totalSize)
            dsize=$($cmd /torrent/$torrent bytesToDownload)
            prog=$($cmd /torrent/$torrent bytesDownloaded)
            speed=$($cmd /torrent/$torrent downloadSpeed)
            seed=$($cmd /torrent/$torrent seedersConnected)
            leech=$($cmd /torrent/$torrent leechersConnected)
            priority=$($cmd /torrent/$torrent priority)
            sl=$(printf "[%d|%d]" $seed $leech)
            pri=$(printf "(%d)" $priority)
            printf "%3.0lf%% of %11d %4.0lf kb/s %8s %4s %s\n" $((100*$prog/$dsize)) $dsize $(($speed/1000)) $sl $pri "$name"
            i=$(($i+1))
        done ;;
    name|stop|start|remove|files)
        if (( ${#2} < 4 )); then
            torrents=($($cmd /core torrents))
            torrent=${torrents[$2]}
        else torrent=$2; fi
        case "$1" in
            name)
                $cmd /torrent/$torrent name ;;
            start)
                if [ "$2" ]; then res=$($cmd /core start $torrent)
                else res=$($cmd /core startAll); fi;;
            stop)
                if [ "$2" ]; then res=$($cmd /core stop $torrent)
                else res=$($cmd /core stopAll); fi;;
            remove)
                # qdbus boolean bug workaround: use dbus-send instead
                res=$(dbus-send --type=method_call --dest=$loc /core org.ktorrent.core.remove string:"$torrent" boolean:false) ;;
            files)
                n=$($cmd /torrent/$torrent numFiles)
                for (( i=0; i < $n; i++ )); do
                    path=$($cmd /torrent/$torrent filePath $i)
                    pct=$($cmd /torrent/$torrent filePercentage $i)
                    size=$($cmd /torrent/$torrent fileSize $i)
                    priority=$($cmd /torrent/$torrent filePriority $i)
                    printf "%d %3.0lf%% of %11d [%d] %s\n" $i $pct $size $priority "$path"
                done ;;
        esac ;;
    pri|priority|prioritize)
        if [ $3 ]; then
            if (( ${#2} < 4 )); then
                torrents=($($cmd /core torrents))
                torrent=${torrents[$2]}
            else torrent=$2; fi
            if [ ! $torrent ]; then exit; fi
            n=$($cmd /torrent/$torrent numFiles)
            if [ $4 ]; then
                res=$($cmd /torrent/$torrent setFilePriority $3 $4)
            else
                case $3 in
                    equal|equalize)
                        for (( i=0; i < $n; i++ )); do
                            res=$($cmd /torrent/$torrent setFilePriority $i 40)
                        done ;;
                    inc|increasing)
                        for (( i=0; i < $n; i++ )); do
                            pri=$(printf "%2.0lf" $(((4*$i/$n+3)*10)))
                            res=$($cmd /torrent/$torrent setFilePriority $i $pri)
                        done ;;
                    dec|decreasing)
                        for (( i=0; i < $n; i++ )); do
                            pri=$(printf "%2.0lf" $(((4*($n-$i-1)/$n+3)*10)))
                            res=$($cmd /torrent/$torrent setFilePriority $i $pri)
                        done ;;
                    first)
                        m=$(($n < 3 ? $n : 3))
                        for (( i=0; i < $m; i++ )); do
                            res=$($cmd /torrent/$torrent setFilePriority $i $(((6-$i)*10)))
                        done
                        for (( i=3; i < $n; i++ )) do
                            res=$($cmd /torrent/$torrent setFilePriority $i 30)
                        done ;;
                    *)
                        res=$($cmd /torrent/$torrent setPriority $3) ;;
                esac
            fi
        else echo Too few arguments!; fi ;;
    clear)
        torrents=$($cmd /core torrents)
        for torrent in $torrents; do
            res=$(dbus-send --type=method_call --dest=$loc /core org.ktorrent.core.remove string:"$torrent" boolean:false)
        done ;;
    quit)
        res=$($cmd /MainApplication quit) ;;
    *)
        echo "Unrecognized command: '$1'" ;;
esac