Skip to content

Commit

Permalink
Capture error cases involving invalid network device paths and sleep …
Browse files Browse the repository at this point in the history
…before returning to resolve CPU consuming loop due to interval type of i3blocks. Addresses regolith-linux/regolith-desktop#532. (#111)
  • Loading branch information
kgilmer authored Jan 10, 2021
1 parent 4d4944c commit 2238ee7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
11 changes: 11 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -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 <[email protected]> Sun, 10 Jan 2021 11:25:46 -0800

regolith-i3xrocks-config (3.5.4-1) bionic; urgency=medium

[ Moritz Heiber ]
Expand Down
8 changes: 7 additions & 1 deletion scripts/net-traffic
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,30 @@

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

# some default values for arguments"
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
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
Expand Down

0 comments on commit 2238ee7

Please sign in to comment.