This repository has been archived on 2023-03-02. You can view files and clone it, but cannot push or open issues or pull requests.
dotfiles/.local/bin/statusbar/sb-torrent

28 lines
1001 B
Plaintext
Raw Normal View History

2021-03-10 10:28:54 +01:00
#!/usr/bin/env sh
######################################################################
# @author : swytch
# @file : sb-torrent
# @license : GPLv3
# @created : Sunday March 7, 2021 18:19:04 CET
#
# @description : torrent block for dwmblocks
######################################################################
pid="$(pidof transmission-daemon)"
[ -z "$pid" ] && exit
out="$(transmission-remote --list)"
cntd="$(echo "$out" | grep -e "Downloading" | wc -l)"
cntu="$(echo "$out" | grep -e "Seeding" | wc -l)"
2021-03-15 23:34:01 +01:00
cntud="$(echo "$out" | grep -e "Up & Down" | wc -l)"
2021-04-09 11:20:27 +02:00
cntd="$(expr $cntd + $cntud)"
2021-03-15 23:34:01 +01:00
cntu="$(expr $cntu + $cntud)"
2021-03-10 10:28:54 +01:00
infos="$(echo "$out"| tail -n1)"
2021-03-16 00:19:00 +01:00
spdd="$(echo "$infos" | awk -F " " '{ printf "%.2f", $5/1024 }')"
spdu="$(echo "$infos" | awk -F " " '{ printf "%.2f", $4/1024 }')"
2021-03-10 10:28:54 +01:00
[ 0 -ne $cntd ] && down="$(printf "%s(%sM)" "$cntd" "$spdd")" || down="---"
[ 0 -ne $cntu ] && up="$(printf "%s(%sM)" "$cntu" "$spdu")" || up="---"
printf "  %s/%s " "$down" "$up"