dwmbar/dwmbarrc

68 lines
1.2 KiB
Text
Raw Normal View History

#!/bin/bash
# Example file, designed to be edited.
DELAY=0.05
2019-10-22 00:19:44 +00:00
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=""
2019-10-23 13:20:26 +00:00
# All modules that you want present in the status bar
MODULES="mpd volumebar wifi redshift disksize ram temperature date time battery"
2019-10-23 13:20:26 +00:00
# Modules that require an active internet connection
ONLINE_MODULES="weather"
2019-10-23 13:20:26 +00:00
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"
}
2019-10-23 13:20:26 +00:00
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"
}
2019-10-23 13:20:26 +00:00
run()
{
get_internet
for module in $MODULES; do
run_module $module
done
get_bar
sleep $DELAY;
}
run