mirror of
https://git.adityakumar.xyz/dwmbar.git
synced 2024-11-09 22:19:45 +00:00
83de952093
Bash backgrounding is bloat
92 lines
2.4 KiB
Bash
Executable file
92 lines
2.4 KiB
Bash
Executable file
#!/bin/bash
|
|
# Copyright 2019 Archie Hilton <archie.hilton1@gmail.com>
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
VERSION="0.2"
|
|
|
|
DEFAULT_CONFIG_DIR="/usr/share/dwmbar"
|
|
DEFAULT_MODULES_DIR="$DEFAULT_CONFIG_DIR/modules"
|
|
DEFAULT_BAR_LOCATION="$DEFAULT_CONFIG_DIR/bar.sh"
|
|
DEFAULT_CONFIG_LOCATION="$DEFAULT_CONFIG_DIR/config"
|
|
|
|
CONFIG_DIR="/home/$USER/.config/dwmbar"
|
|
CUSTOM_DIR="$CONFIG_DIR/custom"
|
|
CONFIG_FILE="$CONFIG_DIR/config"
|
|
CACHE_DIR="$CONFIG_DIR/.cache"
|
|
|
|
INTERNET=0
|
|
export INTERNET
|
|
|
|
print_help(){
|
|
echo "dwmbar $VERSION
|
|
-v Display this help message.
|
|
-c Copy default files to /home/$USER/.config/dwmbar
|
|
"
|
|
}
|
|
|
|
copy_usr_to_home(){
|
|
[[ ! -d $CONFIG_DIR ]] && cp -r /usr/share/dwmbar $CONFIG_DIR
|
|
[[ ! -f $CONFIG_FILE ]] && cp /usr/share/dwmbar/config $CONFIG_FILE
|
|
[[ ! -d $CUSTOM_DIR ]] && mkdir $CUSTOM_DIR
|
|
[[ ! -d $CACHE_DIR ]] && mkdir $CACHE_DIR
|
|
}
|
|
|
|
check_files(){
|
|
if [[ ! -d $DEFAULT_CONFIG_DIR ]]; then
|
|
echo "$DEFAULT_CONFIG_DIR does not exist." > /dev/stderr
|
|
exit 1
|
|
fi
|
|
|
|
if [[ ! -d $DEFAULT_MODULES_DIR ]]; then
|
|
echo "$DEFAULT_MODULES_DIR does not exist." > /dev/stderr
|
|
exit 1
|
|
fi
|
|
|
|
if [[ ! -f $DEFAULT_BAR_LOCATION ]]; then
|
|
echo "$DEFAULT_BAR_LOCATION does not exist." > /dev/stderr
|
|
exit 1
|
|
fi
|
|
|
|
if [[ ! -f $DEFAULT_CONFIG_LOCATION ]]; then
|
|
echo "$DEFAULT_CONFIG_LOCATION does not exist." > /dev/stderr
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
while getopts 'vc' flag; do
|
|
case "${flag}" in
|
|
v) print_help
|
|
exit 0 ;;
|
|
c) copy_usr_to_home
|
|
exit 0 ;;
|
|
esac
|
|
done
|
|
|
|
check_files
|
|
|
|
while :; do
|
|
date=$(date +'%S')
|
|
if [ $(( 10#$date % 5 )) -eq 0 ]; then
|
|
echo "check"
|
|
wget --spider -q www.google.com
|
|
|
|
if [[ $? -eq 0 ]]; then
|
|
INTERNET=0
|
|
else
|
|
INTERNET=1
|
|
fi
|
|
fi
|
|
xsetroot -name "$INTERNET $(exec $DEFAULT_BAR_LOCATION)"
|
|
# xsetroot -name "$INTERNET"
|
|
done
|