dmenu-scripts/dmenu-transmission

66 lines
1.3 KiB
Plaintext
Raw Normal View History

2022-08-05 13:05:30 +02:00
#!/bin/env bash
2023-11-04 22:03:43 +01:00
load_config() {
source $HOME/.config/dmenu/config
}
2023-11-04 22:03:43 +01:00
move() {
declare -a paths=(
"$HOME/vids/anime"
"$HOME/vids/movies"
"$HOME/vids/tv-shows"
"$HOME/docs/manga"
"$HOME/docs/lightnovels"
"$HOME/games/torrents"
)
2022-08-05 13:05:30 +02:00
2023-11-04 22:03:43 +01:00
current=$(transmission-remote -t $1 -i | grep -i location | awk '{print $2}')
2022-08-05 13:05:30 +02:00
2023-11-04 22:03:43 +01:00
choice=$(printf '%s\n' "${paths[@]}" | $DMENU -i -p "Current: $current")
2022-08-05 13:05:30 +02:00
2023-11-04 22:03:43 +01:00
[ -z "$choice" ] && quick-notify "Transmission" "No path chosen" && exit
2022-08-05 13:05:30 +02:00
2023-11-04 22:03:43 +01:00
[ ! -d "$choice" ] && mkdir -p "$choice"
2022-08-05 13:05:30 +02:00
2023-11-04 22:03:43 +01:00
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
}
2023-11-04 22:03:43 +01:00
menu() {
case "$(printf "Start\\nStop\\nMove\\nRemove" | $DMENU -i -p "Torrent Action: ")" in
Remove)
transmission-remote -t $id -rad
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
}
2023-11-04 22:03:43 +01:00
main() {
load_config
2023-11-04 22:03:43 +01:00
id=$(transmission-remote -l | $DMENU -i -l 10 | awk '{print $1}' | sed 's/*//')
2022-08-05 13:05:30 +02:00
2023-11-04 22:03:43 +01:00
[ -z "$id" ] && exit 0
2022-08-05 13:05:30 +02:00
2023-11-04 22:03:43 +01:00
menu
2022-08-05 13:05:30 +02:00
}
main $@