From f5fbbb7572a685c695515d23969fbfaf7b4d011f Mon Sep 17 00:00:00 2001 From: "Archie Hilton (thytom)" Date: Wed, 23 Oct 2019 14:46:23 +0100 Subject: [PATCH] Updated TODO, fixed internet modules --- TODO.org | 11 ++++------- dwmbarrc | 28 +++++++++++++++++----------- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/TODO.org b/TODO.org index 2f06532..f991009 100644 --- a/TODO.org +++ b/TODO.org @@ -11,15 +11,13 @@ Each module writes to stdout. * Todo List - Different file for customizable stuff -- Add --rootdir option to install script +- dwmbar uses /usr/bin/dwmbarrc if no .config/dwmbar/dwmbarrc exists. -Bugs to fix -- Sometimes double | -- Cpuload module is way too slow. fix. (archie) -- Status bar starts to close to screen (add space) (archie) +Bugs to fix: +None Modules to Write: -*We are more than welcome to accept ideas and pull requests for future +- We are more than welcome to accept ideas and pull requests for future modules! Working Modules: @@ -44,4 +42,3 @@ Working Modules: Scripts: - Individual module delays. -- Make install script install locally and not for root. diff --git a/dwmbarrc b/dwmbarrc index 626e7d0..84534ea 100755 --- a/dwmbarrc +++ b/dwmbarrc @@ -11,30 +11,32 @@ PADDING="$USER@$HOSTNAME " OUTPUT_CACHE="/home/$USER/.config/dwmbar/.cache/" OUTPUT="" -# All modules that you want present in the status bar -MODULES="mpd volumebar wifi redshift disksize ram temperature date time battery" +# What modules, in what order +MODULES="mpd weather volumebar wifi internet cpuload temperature battery date time" + # Modules that require an active internet connection -ONLINE_MODULES="weather" +ONLINE_MODULES="weather internet" - -INTERNET=false +INTERNET=1 #0 being true get_internet() { curl -q http://google.com &> /dev/null - if [ $? -eq 0 ]; then - $INTERNET=true + if [[ $? -eq 0 ]]; then + INTERNET=0 else - $INTERNET=false + INTERNET=1 fi } get_bar() { for module in $MODULES; do - module_out=$(cat $OUTPUT_CACHE$module | sed 's/\.$//g') - bar=$bar$module_out + if [[ $INTERNET -eq 0 ]] || [[ $ONLINE_MODULES != *"$module"* ]];then + module_out=$(cat $OUTPUT_CACHE$module | sed 's/\.$//g') + bar=$bar$module_out + fi done # Uncomment to remove last separator # bar=$(echo $bar | sed 's/.$//g') @@ -58,7 +60,11 @@ run() { get_internet for module in $MODULES; do - run_module $module + if [[ $INTERNET -eq 0 ]]; then + run_module $module + else + [[ $ONLINE_MODULES != *"$module"* ]] && run_module $module + fi done get_bar sleep $DELAY;