read in previous data
This commit is contained in:
parent
52d9140820
commit
bb8495f27d
1 changed files with 2 additions and 4 deletions
|
@ -11,13 +11,11 @@ case "$BLOCK_BUTTON" in
|
||||||
esac
|
esac
|
||||||
|
|
||||||
logfile="${XDG_CACHE_HOME:-$HOME/.cache}/netlog"
|
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)))"
|
rxcurrent="$(($(paste -d '+' /sys/class/net/[ew]*/statistics/rx_bytes)))"
|
||||||
txcurrent="$(($(paste -d '+' /sys/class/net/[ew]*/statistics/tx_bytes)))"
|
txcurrent="$(($(paste -d '+' /sys/class/net/[ew]*/statistics/tx_bytes)))"
|
||||||
|
|
||||||
printf "🔻%sKiB 🔺%sKiB\\n" \
|
printf "🔻%sKiB 🔺%sKiB\\n" "$(((rxcurrent-rxprev)/1024))" "$(((txcurrent-txprev)/1024))"
|
||||||
"$(((rxcurrent-${prevdata%% *})/1024))" \
|
|
||||||
"$(((txcurrent-${prevdata##* })/1024))"
|
|
||||||
|
|
||||||
echo "$rxcurrent $txcurrent" > "$logfile"
|
echo "$rxcurrent $txcurrent" > "$logfile"
|
||||||
|
|
Loading…
Reference in a new issue