diff options
author | Manuel Palenzuela <manuelpalenzuelamerino@gmail.com> | 2019-10-23 14:20:26 +0100 |
---|---|---|
committer | Manuel Palenzuela <manuelpalenzuelamerino@gmail.com> | 2019-10-23 14:20:26 +0100 |
commit | 5f13817a9e9f1f6528456a9667451a9041911558 (patch) | |
tree | 06afadc2cb2627687a2a9b25943435e3fcc450c3 | |
parent | aa8ca39b7c13ecdcac9ab1aa3281fe967f5cbdde (diff) |
Added internet functionality (1)
-rwxr-xr-x | dwmbarrc | 27 |
1 files changed, 24 insertions, 3 deletions
@@ -11,9 +11,27 @@ 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" +# Modules that require an active internet connection +ONLINE_MODULES="weather" -get_bar(){ + +INTERNET=false + +get_internet() +{ + curl -q http://google.com &> /dev/null + + if [ $? -eq 0 ]; then + $INTERNET=true + else + $INTERNET=false + fi +} + +get_bar() +{ for module in $MODULES; do module_out=$(cat $OUTPUT_CACHE$module | sed 's/\.$//g') bar=$bar$module_out @@ -23,7 +41,8 @@ get_bar(){ echo "$bar$PADDING" } -run_module(){ +run_module() +{ if [[ -f "$CUSTOM_DIR$1" ]] then out="$(exec $CUSTOM_DIR$1)" @@ -35,7 +54,9 @@ run_module(){ echo $out > "$OUTPUT_CACHE$module" } -run(){ +run() +{ + get_internet for module in $MODULES; do run_module $module done |