summaryrefslogtreecommitdiff
path: root/bin/rt
blob: 66c8a864ccd060a5752b366adb8088d5e4dabbb1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/bin/bash
. $HOME/.shenv

# first check that there exist the dirs we need

if [ ! -e "$HOME/local/rt/watch" -o ! -d "$HOME/local/rt/session" -o ! -d "$HOME/local/rt/incomplete" -o ! -e "$HOME/local/rt/complete" ]; then
    echo "I was asked to start rtorrent, but one of the dirs in ~/local/rt is missing" >&2
    echo "(myrepos fixups should do it)" >&2
    exit 1
fi

# start rtorrent under dtach if it's not running

if ! pgrep -u $LOGNAME rtorrent >/dev/null; then
    rm -f $HOME/local/rt/session/dtach.socket
    TERM=xterm nice -n 19 dtach -n $HOME/local/rt/session/dtach.socket rtorrent
fi

# if we're not at a dumb terminal (so this script can be shoved in a
# crontab), try to attach what we (maybe) just made

# this is a bashism
if [ -t 1 ]; then
    dtach -a $HOME/local/rt/session/dtach.socket
fi