Last active
December 17, 2015 12:58
-
-
Save wizardishungry/5613184 to your computer and use it in GitHub Desktop.
Make transmission turn on the alternate bandwidth limits (turtle mode) when you login over ssh and turn back on when you log out of the last ssh connection.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Usage: transmission-turtle [true|false] | |
ENDPOINT=http://localhost:9091 | |
CRED='admin:coolpassword' | |
################################################################################ | |
ENDPOINT=$ENDPOINT/transmission/rpc | |
HEADER=`curl -s -u "$CRED" -I $ENDPOINT | tr -d "\015" | egrep ^X-Transmission-Session-Id ` | |
curl -s -H "$HEADER" -u "$CRED" \ | |
$ENDPOINT -d "{\"method\": \"session-set\",\"arguments\":{\"alt-speed-enabled\":$1}}" | sed -e 's/.*:/ /g; s/["}]//g;' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# If we're the last ssh login deselect the turtle icon in tranmission | |
if [ -f `which tranmission-turtle 2> /dev/null` ]; then | |
ps ax | egrep "^ *$PPID *.*ssh" > /dev/null | |
if [ $? -eq 0 ]; then | |
# We're in an ssh login | |
MY_TTY=`tty | sed 's#.*/##' ` | |
who | grep -v $MY_TTY |grep \( > /dev/null | |
if [ $? -ne 0 ]; then | |
# We're the last ssh connection | |
echo -n "🐢De-Turtling Transmission... " | |
transmission-turtle false | |
fi | |
fi | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# If we're a fresh ssh login click the turtle icon in tranmission | |
if [ -f `which tranmission-turtle 2> /dev/null` ]; then | |
MY_TTY=`tty | sed 's#.*/##' ` | |
who | grep $MY_TTY |grep \( > /dev/null | |
if [ $? -eq 0 ]; then | |
echo -n "🐢Turtling Transmission... " | |
transmission-turtle true | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment