dmenu-scripts/dmenu-transmission
2023-02-22 19:24:09 +01:00

61 lines
1.5 KiB
Bash
Executable File

#!/bin/env bash
load_config () {
source $HOME/.config/dmenu/config
}
move () {
declare -a paths=(
"$HOME/vids/anime"
"$HOME/vids/movies"
"$HOME/vids/tv-shows"
"$HOME/docs/manga"
"$HOME/docs/lightnovels"
"$HOME/games/torrents"
)
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
}
menu () {
case "$(printf "Start\\nStop\\nMove\\nRemove" | $DMENU -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
}
main () {
load_config
id=$(transmission-remote -l | $DMENU -l 10 | awk '{print $1}'| sed 's/*//')
[ -z "$id" ] && exit 0
menu
}
main $@