-
Notifications
You must be signed in to change notification settings - Fork 13
/
trxo
executable file
·51 lines (40 loc) · 1.04 KB
/
trxo
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
unset confdir_parent conf_list conf retval
unset HOST AUTH
[ $# -eq 0 ] && { echo "missing command parameter"; exit; }
[ $# -ne 1 ] && { echo "too many command parameters"; exit; }
if [ -n "$XDG_CONFIG_HOME" ]; then
confdir_parent=$XDG_CONFIG_HOME
else
confdir_parent=~/.config
fi
conf_list=(
"$confdir_parent"/trxo/config
"$confdir_parent"/trxo.config
~/.trxo
)
for entry in "${conf_list[@]}"; do
if [ -f "$entry" ]; then
echo found config file at "$entry"
conf="$entry"
break
fi
done
[ -f "$conf" ] && source "$conf"
if [ -n "$TR_HOST" ]; then
echo "found host: $TR_HOST"
if [ -n "$TR_PORT" ]; then
echo "found host port: $TR_PORT"
HOST=${TR_HOST}:${TR_PORT}
else
HOST=${TR_HOST}
fi
fi
[ -n "$TR_AUTH" ] && AUTH="--auth $TR_AUTH"
retval=$(transmission-remote $HOST $AUTH --add "$1")
echo "$retval"
if [[ ${retval##*responded: } == '"success"' ]]; then
notify-send --hint int:transient:1 "Torrent added successfuly"
else
notify-send --hint int:transient:1 "Failed adding torrent" "$retval"
fi