Improved -c functionality

This commit is contained in:
Archie Hilton (thytom) 2019-11-06 14:37:29 +00:00
parent 959305da2d
commit f7ca49ffe7
2 changed files with 14 additions and 11 deletions

6
bar.sh
View file

@ -17,7 +17,11 @@
MODULES_DIR="/usr/share/dwmbar/modules/" MODULES_DIR="/usr/share/dwmbar/modules/"
OUTPUT_CACHE="/home/$USER/.config/dwmbar/.cache/" if [[ -d $CACHE_DIR ]]; then
OUTPUT_CACHE="$CACHE_DIR"
else
OUTPUT_CACHE="/home/$USER/.config/dwmbar/.cache/"
fi
OUTPUT="" OUTPUT=""
CONFIG_FILE="/home/$USER/.config/dwmbar/config" CONFIG_FILE="/home/$USER/.config/dwmbar/config"

19
dwmbar
View file

@ -23,7 +23,8 @@ DEFAULT_CONFIG_LOCATION="$DEFAULT_CONFIG_DIR/config"
CONFIG_DIR="/home/$USER/.config/dwmbar" CONFIG_DIR="/home/$USER/.config/dwmbar"
CUSTOM_DIR="$CONFIG_DIR/custom" CUSTOM_DIR="$CONFIG_DIR/custom"
CONFIG_FILE="$CONFIG_DIR/config" CONFIG_FILE="$CONFIG_DIR/config"
CACHE_DIR="$CONFIG_DIR/.cache" CACHE_DIR="$HOME/.cache/dwmbar/"
export CACHE_DIR
INTERNET=1 INTERNET=1
export INTERNET export INTERNET
@ -39,31 +40,29 @@ copy_usr_to_home(){
[[ ! -d $CONFIG_DIR ]] && cp -r /usr/share/dwmbar $CONFIG_DIR [[ ! -d $CONFIG_DIR ]] && cp -r /usr/share/dwmbar $CONFIG_DIR
[[ ! -f $CONFIG_FILE ]] && cp /usr/share/dwmbar/config $CONFIG_FILE [[ ! -f $CONFIG_FILE ]] && cp /usr/share/dwmbar/config $CONFIG_FILE
[[ ! -d $CUSTOM_DIR ]] && mkdir $CUSTOM_DIR [[ ! -d $CUSTOM_DIR ]] && mkdir $CUSTOM_DIR
[[ ! -d $CACHE_DIR ]] && mkdir $CACHE_DIR
} }
check_files(){ check_files(){
if [[ ! -d $DEFAULT_CONFIG_DIR ]]; then if [[ ! -d "$DEFAULT_CONFIG_DIR" ]]; then
echo "$DEFAULT_CONFIG_DIR does not exist." > /dev/stderr echo "$DEFAULT_CONFIG_DIR does not exist." > /dev/stderr
exit 1 exit 1
fi fi
if [[ ! -d $DEFAULT_MODULES_DIR ]]; then if [[ ! -d "$DEFAULT_MODULES_DIR" ]]; then
echo "$DEFAULT_MODULES_DIR does not exist." > /dev/stderr echo "$DEFAULT_MODULES_DIR does not exist." > /dev/stderr
exit 1 exit 1
fi fi
if [[ ! -d $CACHE_DIR ]]; then if [[ ! -d "$CACHE_DIR" ]]; then
echo "$CACHE_DIR does not exist." > /dev/stderr mkdir -p "$CACHE_DIR"
exit 1 fi
fi
if [[ ! -f $DEFAULT_BAR_LOCATION ]]; then if [[ ! -f "$DEFAULT_BAR_LOCATION" ]]; then
echo "$DEFAULT_BAR_LOCATION does not exist." > /dev/stderr echo "$DEFAULT_BAR_LOCATION does not exist." > /dev/stderr
exit 1 exit 1
fi fi
if [[ ! -f $DEFAULT_CONFIG_LOCATION ]]; then if [[ ! -f "$DEFAULT_CONFIG_LOCATION" ]]; then
echo "$DEFAULT_CONFIG_LOCATION does not exist." > /dev/stderr echo "$DEFAULT_CONFIG_LOCATION does not exist." > /dev/stderr
exit 1 exit 1
fi fi