dotfiles

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit bb8495f27d56705d7ac55bd38c52cc605734cdb6
parent 52d9140820d3e39446cb8414220c9bc5a052216c
Author: Luke Smith <luke@lukesmith.xyz>
Date:   Sat, 30 May 2020 17:50:37 -0400

read in previous data

Diffstat:
M.local/bin/statusbar/nettraf | 6++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/.local/bin/statusbar/nettraf b/.local/bin/statusbar/nettraf @@ -11,13 +11,11 @@ case "$BLOCK_BUTTON" in esac logfile="${XDG_CACHE_HOME:-$HOME/.cache}/netlog" -prevdata="$(cat "$logfile")" || echo "0 0" > "$logfile" +read -r rxprev txprev < "$logfile" rxcurrent="$(($(paste -d '+' /sys/class/net/[ew]*/statistics/rx_bytes)))" txcurrent="$(($(paste -d '+' /sys/class/net/[ew]*/statistics/tx_bytes)))" -printf "🔻%sKiB 🔺%sKiB\\n" \ - "$(((rxcurrent-${prevdata%% *})/1024))" \ - "$(((txcurrent-${prevdata##* })/1024))" +printf "🔻%sKiB 🔺%sKiB\\n" "$(((rxcurrent-rxprev)/1024))" "$(((txcurrent-txprev)/1024))" echo "$rxcurrent $txcurrent" > "$logfile"