dotfiles-old/.local/bin/transadd

66 lines
1.7 KiB
Plaintext
Raw Normal View History

2022-03-10 03:42:22 +00:00
#!/usr/bin/env sh
# script copied from Luke Smith to add a torrent
# removed part of first line that uses i3blocks
# modifications to allow the user to select the download directory using lf
#modifications to interface with remote transmission server
TRANSMISSION_REMOTE="nagato:9091"
OPTS="default
lf_select
lf_last"
DEST="remote
local"
DEST_OPT="local" #"$(echo "$DEST" | bemenu -p "select destination machine: ")"
2022-03-10 03:42:22 +00:00
if [ "$DEST_OPT" = "local" ]; then
pgrep -x transmission-da > /dev/null || (trans-init && notify-send "Starting transmission daemon..." && sleep 3)
fi
OPT="$(echo "$OPTS" | bemenu -p "download to:")"
if [ "$OPT" = "lf_select" ]; then
if [ ! -f ~/.cache/lf/lastpath ]; then
mkdir -p ~/.cache/lf/
touch ~/.cache/lf/lastpath
echo "~" > ~/.cache/lf/lastpath
fi
$TERMINAL -e lf -last-dir-path ~/.cache/lf/lastpath "$(cat ~/.cache/lf/lastpath)"
SEL="$(cat ~/.cache/lf/lastpath)"
elif [ "$OPT" = "lf_last" ]; then
SEL="$(cat ~/.cache/lf/lastpath)"
elif [ "$OPT" = "default" ]; then
SEL=""
else
SEL=""
notify-send "ERROR"
exit
fi
#if [ "$TRANSMISSION_REMOTE" ]; then
# SEL_REM="$(echo "$SEL" | sed 's/^\/media\/nagato/\/media\/storage/g')"
#fi
2022-03-10 03:42:22 +00:00
#if [ "$DEST_OPT" = "remote" ]; then
# if [ "$SEL_REM" ]; then
# transmission-remote $TRANSMISSION_REMOTE -a "$@" -w "$SEL_REM" && notify-send " Transmission-daemon" "Torrent added to $SEL"
# else
# transmission-remote $TRANSMISSION_REMOTE -a "$@" && notify-send " Transmission-daemon" "Torrent added."
# fi
#else
2022-03-10 03:42:22 +00:00
if [ -d "$SEL" ]; then
transmission-remote -a "$@" -w "$SEL" && notify-send " Transmission-daemon" "Torrent added to $SEL"
else
transmission-remote -a "$@" && notify-send " Transmission-daemon" "Torrent added."
fi
#fi