#!/bin/bash # Copyright 2019 Archie Hilton # 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 . VERSION="0.1" DEFAULT_CONFIG_DIR="/usr/share/dwmbar" DEFAULT_MODULES_DIR="$DEFAULT_CONFIG_DIR/modules" DEFAULT_RC_LOCATION="$DEFAULT_CONFIG_DIR/dwmbarrc" RC_LOCATION="/home/$USER/.config/dwmbar/dwmbarrc" CONFIG_DIR="/home/$USER/.config/dwmbar" MODULES_DIR="$CONFIG_DIR/modules" CUSTOM_DIR="$MODULES_DIR/custom" DWMBARRC="$CONFIG_DIR/dwmbarrc" CACHE_DIR="$CONFIG_DIR/.cache" 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 $DWMBARRC ]] && cp /usr/share/dwmbar/dwmbarrc $DWMBARRC [[ ! -d $MODULES_DIR ]] && cp /usr/share/dwmbar/modules $MODULES_DIR [[ ! -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_RC_LOCATION ]]; then echo "$DEFAULT_RC_LOCATION does not exist." > /dev/stderr exit 1 fi } while getopts 'v' flag; do case "${flag}" in v) print_help exit 0 ;; c) copy_usr_to_home exit 0 ;; esac done check_files while :; do xsetroot -name "$(exec $RC_LOCATION)" done