Mint Serena 64 bit using the Mate desktop environment. Most of the following scripts will run on this machine, although some have only been tested with the Gnome desktop. Extra software requirements can be met by the Ubuntu and safe PPA repositories. Scripts may be re-written or added to from time to time, the date serves as the version number. Syntax highlighting on these pages is provided by GVim's "Convert to HTML" option.

What torrents?

# Filename:
# Version: 070811
# Author: robz
# This script gives a quick peek and an opportunity to edit, what you have
# active in the Transmission bit torrent client, without loading the program
# itself. It runs from a launcher located in my $HOME/Torrents/Complete/
# directory, the line for the "Command:" box of the launcher being:
# gnome-terminal --title="Check Torrents" -x sh -c "path to/"
# Deletions are sent to Trash rather than rm'd, just in case you fcuk up :)

C2="\e[1;32m" C6="\e[1;36m" C7="\e[1;37m"                # Green cyan white.
TSCPT="$0"                                               # Path to this script.
TRASH=$HOME/.local/share/Trash                           # Trash location.
TRNTS=$HOME/.config/transmission/torrents                # Trackers location.
CLMNS=$(($(ls "$TRNTS" | wc -L)+10))                     # Terminal columns.
LINES=$(ls "$TRNTS" | wc -l)                             # Terminal lines.
VRBLS=$(ls "$TRNTS" | nl)                                # Torrent list verbal.
VRBL2="Select number to delete or hit Enter to exit. "   # More verbal.

if [ "$LINES" -eq "0" ]; then                            # Anything in there?
VRBLS="No trackers are loaded."; VRBL2="Hit Enter to exit. "; CLMNS=25

# Escape sequences auto size the terminal window and set the background colour.
echo -ne "\e[8;$((${LINES}+5));${CLMNS}t"; echo -ne "\e[44m""\e[37m""\033[2J"
echo -e $C7"Active torrents $LINES:\n""$C6"; echo "$VRBLS"; echo -e $C2

read -n1 -p "$VRBL2" SEL                                 # Delete or exit.
if [[ "$LINES" -gt "0" && "$SEL" -gt "0" && "$LINES" -ge "$SEL" ]]; then
MVFL="$TRNTS/$(ls "$TRNTS" | sed -n "$SEL"p)"            # Get selection.
INFO="$TRASH/info/$(basename $MVFL).trashinfo"           # Trash info location.
echo "[Trash Info]" > "$INFO"                            # Create Trash info.
echo "Path=$TRNTS/$(basename $MVFL)" >> "$INFO"
echo "DeletionDate=$(date +%FT%T)" >> "$INFO"
mv "$MVFL" "$TRASH/files"                                # Send file to trash.
# Restart terminal and re-list remaining torrent tracker files.
gnome-terminal --geometry=+0+0 --title="Check Torrents" -x sh -c "$TSCPT"

No comments: