dmenu-scripts/dmenu-transmission

49 lines
1.3 KiB
Plaintext
Raw Normal View History

2022-08-05 13:05:30 +02:00
#!/bin/env bash
id=$(transmission-remote -l | dmenu -l 10 | awk '{print $1}'| sed 's/*//')
[ -z "$id" ] && exit 0
2022-08-05 13:05:30 +02:00
move () {
declare -a paths=(
2022-09-02 08:53:36 +02:00
"$HOME/vids/anime"
"$HOME/vids/movies"
2022-10-14 12:00:51 +02:00
"$HOME/vids/tv-shows"
2022-09-02 08:53:36 +02:00
"$HOME/docs/manga"
"$HOME/docs/lightnovels"
"$HOME/games/torrents"
2022-08-05 13:05:30 +02:00
)
current=$(transmission-remote -t 1 -i | grep -i location | awk '{print $2}')
choice=$(printf '%s\n' "${paths[@]}" | dmenu -p "Current: $current")
[ -z "$choice" ] && quick-notify "Transmission" "No path chosen" && exit
[ ! -d "$choice" ] && mkdir -p "$choice"
if transmission-remote -t $1 --move $choice ; then
quick-notify "Transmission" "Moved $1 to $choice"
else
quick-notify "Transmission" "Couldn't move $1 to $choice"
fi
}
case "$(printf "Start\\nStop\\nMove\\nRemove" | dmenu -p "Torrent Action: ")" in
2022-08-22 08:33:29 +02:00
Remove) transmission-remote -t $id -rad
2022-08-05 13:05:30 +02:00
quick-notify "Transmission" "Removed $id"
;;
Start) transmission-remote -t $id -s
quick-notify "Transmission" "Started $id"
;;
Stop) transmission-remote -t $id -S
quick-notify "Transmission" "Stoped $id"
;;
Move) move $id
;;
*) quick-notify "Transmission" "No action chosen"
;;
esac