From daf2829167571cec6b78a7a3abe511b90b40071d Mon Sep 17 00:00:00 2001 From: Hekuran <62762955+narukeh@users.noreply.github.com> Date: Sat, 30 May 2020 17:27:01 +0200 Subject: [PATCH 1/3] create netlog if empty it would not run without an existing nonempty log file --- .local/bin/statusbar/nettraf | 1 + 1 file changed, 1 insertion(+) diff --git a/.local/bin/statusbar/nettraf b/.local/bin/statusbar/nettraf index 82305c3..a3c9f6f 100755 --- a/.local/bin/statusbar/nettraf +++ b/.local/bin/statusbar/nettraf @@ -14,6 +14,7 @@ logfile="${XDG_CACHE_HOME:-$HOME/.cache}/netlog" prevdata="$(cat "$logfile")" rxcurrent="$(($(paste -d '+' /sys/class/net/[ew]*/statistics/rx_bytes)))" +[ -f "$logfile" ] || echo "0 0" > $logfile txcurrent="$(($(paste -d '+' /sys/class/net/[^lo]*/statistics/tx_bytes)))" printf "🔻%sKiB 🔺%sKiB\\n" \ From 1d95b2210e4935c0dbf5a1ad04fbc9a4739de299 Mon Sep 17 00:00:00 2001 From: Hekuran <62762955+narukeh@users.noreply.github.com> Date: Sat, 30 May 2020 17:29:41 +0200 Subject: [PATCH 2/3] quotes --- .local/bin/statusbar/nettraf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.local/bin/statusbar/nettraf b/.local/bin/statusbar/nettraf index a3c9f6f..f6c5779 100755 --- a/.local/bin/statusbar/nettraf +++ b/.local/bin/statusbar/nettraf @@ -14,7 +14,7 @@ logfile="${XDG_CACHE_HOME:-$HOME/.cache}/netlog" prevdata="$(cat "$logfile")" rxcurrent="$(($(paste -d '+' /sys/class/net/[ew]*/statistics/rx_bytes)))" -[ -f "$logfile" ] || echo "0 0" > $logfile +[ -f "$logfile" ] || echo "0 0" > "$logfile" txcurrent="$(($(paste -d '+' /sys/class/net/[^lo]*/statistics/tx_bytes)))" printf "🔻%sKiB 🔺%sKiB\\n" \ From 7ea15612b4255b62725fc2819e6df05d7df3ff07 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Sat, 30 May 2020 11:41:29 -0400 Subject: [PATCH 3/3] save the file check every time --- .local/bin/statusbar/nettraf | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.local/bin/statusbar/nettraf b/.local/bin/statusbar/nettraf index f6c5779..1de6801 100755 --- a/.local/bin/statusbar/nettraf +++ b/.local/bin/statusbar/nettraf @@ -11,10 +11,9 @@ case "$BLOCK_BUTTON" in esac logfile="${XDG_CACHE_HOME:-$HOME/.cache}/netlog" -prevdata="$(cat "$logfile")" +prevdata="$(cat "$logfile")" || echo "0 0" > "$logfile" rxcurrent="$(($(paste -d '+' /sys/class/net/[ew]*/statistics/rx_bytes)))" -[ -f "$logfile" ] || echo "0 0" > "$logfile" txcurrent="$(($(paste -d '+' /sys/class/net/[^lo]*/statistics/tx_bytes)))" printf "🔻%sKiB 🔺%sKiB\\n" \