Added internet functionality (1)

This commit is contained in:
Manuel Palenzuela 2019-10-23 14:20:26 +01:00
parent aa8ca39b7c
commit 5f13817a9e

View file

@ -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