aboutsummaryrefslogtreecommitdiff
path: root/.local/share/bin/addtorrent
blob: bf238d6f04448c715a5da9ef10d54f74c7f34fac (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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/sh
progname="$(basename "$0")"

title="Torrent"
msg_ok="Torrent successfully added"
msg_err="Could not add torrent"
usage="usage: $progname URL"
err_no_seedbox="error: \$SEEDBOX_LOGIN is not set"

case "$LANG" in
	ja_JP*)
		title="トレント"
		msg_ok="一つのトレントを追加しました"
		msg_err="トレントを追加できませんでした"
		usage="用法: $progname URL"
		err_no_seedbox="エラー: \$SEEDBOX_LOGINに値がありません"
		;;
esac

die() {
	echo "$1"
	exit 1
}

[ $# -eq 0 ] && die "$usage"
[ -z "$SEEDBOX_LOGIN" ] && die "$err_no_seedbox"

ssh "$SEEDBOX_LOGIN" transmission-remote -a "'$(echo "$1" | sed "s/'/'\\''/g")'"
if [ $? -eq 0 ]; then
	msg="$msg_ok"
	urgency="normal"
else
	msg="$msg_err"
	urgency="critical"
fi

notify-send \
	--app-name "$title" \
	--urgency "$urgency" \
	"$title" "$msg"