Fixed CPU issue and made internet work

Bash backgrounding is bloat
This commit is contained in:
Archie Hilton (thytom) 2019-11-01 18:21:46 +00:00
parent 10570d7692
commit 83de952093
2 changed files with 20 additions and 20 deletions

21
bar.sh
View file

@ -23,19 +23,6 @@ OUTPUT=""
CONFIG_FILE="/home/$USER/.config/dwmbar/config" CONFIG_FILE="/home/$USER/.config/dwmbar/config"
source $CONFIG_FILE 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() get_bar()
{ {
for module in $MODULES; do for module in $MODULES; do
@ -64,12 +51,12 @@ run_module()
run() run()
{ {
get_internet
for module in $MODULES; do for module in $MODULES; do
pgrep $module &> /dev/null pgrep $module &> /dev/null
if [[ $? -eq 1 ]] && [[ $INTERNET -eq 0 ]]; then notrunning=$([[ $? -eq 1 ]])
run_module $module & if $notrunning && [[ $INTERNET -eq 0 ]]; then
else run_module $module
elif $notrunning && [[ $INTERNET -eq 1 ]]; then
[[ "$ONLINE_MODULES" != *"$module"* ]] && run_module $module [[ "$ONLINE_MODULES" != *"$module"* ]] && run_module $module
fi fi
done done

19
dwmbar
View file

@ -1,12 +1,10 @@
#!/bin/bash #!/bin/bash
# Copyright 2019 Archie Hilton <archie.hilton1@gmail.com> # Copyright 2019 Archie Hilton <archie.hilton1@gmail.com>
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or # the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version. # (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@ -27,6 +25,9 @@ CUSTOM_DIR="$CONFIG_DIR/custom"
CONFIG_FILE="$CONFIG_DIR/config" CONFIG_FILE="$CONFIG_DIR/config"
CACHE_DIR="$CONFIG_DIR/.cache" CACHE_DIR="$CONFIG_DIR/.cache"
INTERNET=0
export INTERNET
print_help(){ print_help(){
echo "dwmbar $VERSION echo "dwmbar $VERSION
-v Display this help message. -v Display this help message.
@ -75,5 +76,17 @@ done
check_files check_files
while :; do while :; do
xsetroot -name "$(exec $DEFAULT_BAR_LOCATION)" date=$(date +'%S')
if [ $(( 10#$date % 5 )) -eq 0 ]; then
echo "check"
wget --spider -q www.google.com
if [[ $? -eq 0 ]]; then
INTERNET=0
else
INTERNET=1
fi
fi
xsetroot -name "$INTERNET $(exec $DEFAULT_BAR_LOCATION)"
# xsetroot -name "$INTERNET"
done done