Add 'torrent' module for bar and 'torradd' script

This commit is contained in:
Wiktor Zykubek 2020-05-12 12:09:43 +02:00
parent 3426f02017
commit b55baa6af7
3 changed files with 27 additions and 2 deletions

View File

@ -1,16 +1,17 @@
#!/bin/sh #!/bin/sh
sym="|" sym="|"
[ "$(transmission-remote -l | grep %)" ] && delay="10s" || delay="1m"
cd "$HOME/.local/bin/scripts/dwmbar/" || exit 1 cd "$HOME/.local/bin/scripts/dwmbar/" || exit 1
status() { status() {
echo "$(./disk) $sym $(./internet) $sym $(./lamp) $sym $(./music) $sym" \ echo "$(./torrent) $sym $(./disk) $sym $(./internet) $sym $(./lamp) $sym $(./music) $sym" \
"$(./alsa) $sym $(./packages) $sym $(./date) $sym $(./clock)" "$(./alsa) $sym $(./packages) $sym $(./date) $sym $(./clock)"
} }
while :; do while :; do
xsetroot -name " $(status | tr '\n' ' ')" xsetroot -name " $(status | tr '\n' ' ')"
sleep 1m sleep "$delay"
done done

View File

@ -0,0 +1,18 @@
#!/bin/sh
echo ""
data() { transmission-remote -l | grep %; }
[ ! "$(data)" ] && { echo N; exit 1; }
per="$(data | awk '{ print $2 }')"
[ "${per%?}" != 100 ] && echo "$per" || echo ""
data | \
sed "
s/.*Stopped.*//g;
s/.*Seeding.*//g;
s/.*Idle.*//g;
s/.*Uploading.*//g;
s/.*%.*//g
"

6
.local/bin/scripts/torradd Executable file
View File

@ -0,0 +1,6 @@
#!/bin/sh
pidof transmission-daemon >/dev/null || \
(transmission-daemon && notify-send "Starting transmission daemon...")
transmission-remote -a "$@" && notify-send " Torrent added."