#!/bin/bash # Example file, designed to be edited. DELAY=0.05 MODULES_DIR="/home/$USER/.config/dwmbar/modules/" CUSTOM_DIR="/home/$USER/.config/dwmbar/modules/custom/" SEPARATOR=" | " 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" 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 done # Uncomment to remove last separator # bar=$(echo $bar | sed 's/.$//g') echo "$bar$PADDING" } run_module() { if [[ -f "$CUSTOM_DIR$1" ]] then out="$(exec $CUSTOM_DIR$1)" else out="$(exec $MODULES_DIR$1)" fi [[ ! "$out" = "" ]] && [[ ! "$module" = "NULL" ]] && out="$out$SEPARATOR." echo $out > "$OUTPUT_CACHE$module" } run() { get_internet for module in $MODULES; do run_module $module done get_bar sleep $DELAY; } run