From 83de952093c62ead12a2a8d824718befb8cba3aa Mon Sep 17 00:00:00 2001 From: "Archie Hilton (thytom)" Date: Fri, 1 Nov 2019 18:21:46 +0000 Subject: Fixed CPU issue and made internet work Bash backgrounding is bloat --- bar.sh | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) (limited to 'bar.sh') diff --git a/bar.sh b/bar.sh index ca7df84..1955ee7 100755 --- a/bar.sh +++ b/bar.sh @@ -23,19 +23,6 @@ OUTPUT="" CONFIG_FILE="/home/$USER/.config/dwmbar/config" source $CONFIG_FILE -INTERNET=1 #0 being true - -get_internet() -{ - curl -q http://google.com &> /dev/null - - if [[ $? -eq 0 ]]; then - INTERNET=0 - else - INTERNET=1 - fi -} - get_bar() { for module in $MODULES; do @@ -64,12 +51,12 @@ run_module() run() { - get_internet for module in $MODULES; do pgrep $module &> /dev/null - if [[ $? -eq 1 ]] && [[ $INTERNET -eq 0 ]]; then - run_module $module & - else + notrunning=$([[ $? -eq 1 ]]) + if $notrunning && [[ $INTERNET -eq 0 ]]; then + run_module $module + elif $notrunning && [[ $INTERNET -eq 1 ]]; then [[ "$ONLINE_MODULES" != *"$module"* ]] && run_module $module fi done -- cgit v1.2.3