-
Notifications
You must be signed in to change notification settings - Fork 0
/
remseeded
executable file
·44 lines (37 loc) · 1.09 KB
/
remseeded
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
#!/bin/bash
# Remove all seeded (to ratio 1.0) torrents and exit transmission-remote when there are no torrents.
destroy_daemon () {
transmission-remote --exit > /dev/null
sleep 3
}
torrent_ids=$(transmission-remote --list | sed -e '1d;$d;s/^ *//' | cut -f1 -d' ')
if [[ ! "$torrent_ids" ]] ; then
notify-send -t 2000 "No torrents... Destroying Daemon"
destroy_daemon
kill -38 $(pidof dwmblocks)
exit 0
fi
id_count=0
num_removed=0
for id in $torrent_ids
do
id_count=$((id_count + 1))
seeded_ratio=$(transmission-remote --torrent $id --info | grep "Ratio:" | cut -c 10)
if [[ "$seeded_ratio" -gt 0 ]] ; then
transmission-remote --torrent "$id" --remove > /dev/null
num_removed=$((num_removed + 1))
fi
done
if (( "$num_removed" == 1 )) ; then
message="Torrent removed"
elif (( "$num_removed" > 1 )) ; then
message="Torrents removed"
else
message="No torrents fully seeded"
fi
if (( "$num_removed" == "$id_count" )) ; then
message="$message | Destroying daemon"
destroy_daemon
fi
notify-send -t 2000 "$message"
kill -38 $(pidof dwmblocks)