Use read instead of parameter expansions

This commit is contained in:
MaanooAk 2020-05-30 23:25:33 +03:00
parent 52d9140820
commit f15d753501

View File

@ -11,13 +11,14 @@ case "$BLOCK_BUTTON" in
esac
logfile="${XDG_CACHE_HOME:-$HOME/.cache}/netlog"
prevdata="$(cat "$logfile")" || echo "0 0" > "$logfile"
[ -f "$logfile" ] && read 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))"
"$(((rxcurrent-rxprev)/1024))" \
"$(((txcurrent-txprev)/1024))"
echo "$rxcurrent $txcurrent" > "$logfile"