From 2238ee74224a30c5392bed0de106d7ab68e41dc9 Mon Sep 17 00:00:00 2001 From: Ken Gilmer Date: Sun, 10 Jan 2021 12:34:07 -0800 Subject: [PATCH] Capture error cases involving invalid network device paths and sleep before returning to resolve CPU consuming loop due to interval type of i3blocks. Addresses https://github.com/regolith-linux/regolith-desktop/issues/532. (#111) --- debian/changelog | 11 +++++++++++ scripts/net-traffic | 8 +++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 895a954..311f1e7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,14 @@ +regolith-i3xrocks-config (3.5.5-1ubuntu1) bionic; urgency=medium + + [ Moritz Heiber ] + * Added gawk specific testing for temp script (#108) + * Filter all interfaces associated with VPN traffic while determining default route (#110) + + [ Ken Gilmer ] + * Capture error cases involving invalid network device paths and sleep before returning to resolve CPU consuming loop due to interval type of i3blocks. Addresses https://github.com/regolith-linux/regolith-desktop/issues/532. + + -- Regolith Linux Sun, 10 Jan 2021 11:25:46 -0800 + regolith-i3xrocks-config (3.5.4-1) bionic; urgency=medium [ Moritz Heiber ] diff --git a/scripts/net-traffic b/scripts/net-traffic index f905d22..a0d2cad 100755 --- a/scripts/net-traffic +++ b/scripts/net-traffic @@ -2,6 +2,7 @@ set -Eeu -o pipefail +set -x # Note: net-traffic uses interval type 'repeat' so cannot use button events. # See https://github.com/vivien/i3blocks#interval @@ -9,6 +10,7 @@ set -Eeu -o pipefail UP=${label_icon:-$(xrescat i3xrocks.label.up " up")} DN=${label_icon:-$(xrescat i3xrocks.label.dn " dn")} DLY=${DLY:-5} +ERROR_DLY=${ERROR_DLY:-10} RT=${RT:-} # Padding the output to 5 characters to avoid jittering on the bar @@ -16,10 +18,14 @@ NUMFMT="numfmt --to iec --format %f --padding 5" # determine the net interface name IF="${BLOCK_INSTANCE:-$(ip route show default | awk '!/(ppp|tun|tap)/ { print $5 }')}" -[ "$IF" = "" ] && exit IF_PATH="/sys/class/net/${IF}" +if [[ "$IF" == "" || ! -d "$IF_PATH" || ! -f "${IF_PATH}"/statistics/rx_bytes || ! -f "${IF_PATH}"/statistics/tx_bytes ]]; then + sleep "${ERROR_DLY}" + exit 1 +fi + if [ -d "${IF_PATH}/wireless" ]; then NIC=${label_icon:-$(xrescat i3xrocks.label.wifi )} else