Implemented different config file

This commit is contained in:
Manuel Palenzuela 2019-10-24 15:31:03 +01:00
parent 63d1282294
commit ac73412ccb
4 changed files with 28 additions and 14 deletions

View file

@ -13,6 +13,11 @@ Each module writes to stdout.
- Different file for customizable stuff
- dwmbar uses /usr/bin/dwmbarrc if no .config/dwmbar/dwmbarrc exists.
- Delay in archupdates module (if minutes divisible by 5/4)
- Add dependencies like bc
- Have default modules in /usr/share/dwmbar and all the modules in the
.config/dwmbar/modules override the default ones (no need to have a custom
module dir)
- Fix modules like temp cutting out when running
Bugs to fix:
None

14
bar.sh
View file

@ -15,22 +15,22 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
CONFIG_NAME="config"
CONFIG_FILE="/home/$USER/.config/dwmbar/config"
DELAY=$(cat $CONFIG_NAME | grep -E "DELAY" | cut -d '"' -f2)
DELAY=$(cat $CONFIG_FILE | grep -E "DELAY" | cut -d '"' -f2)
MODULES_DIR="/home/$USER/.config/dwmbar/modules/"
CUSTOM_DIR=$(cat $CONFIG_NAME | grep -E "CUSTOM_DIR" | cut -d '"' -f2)
SEPARATOR=$(cat $CONFIG_NAME | grep -E "SEPARATOR" | cut -d '"' -f2)
PADDING=$(cat $CONFIG_NAME | grep -E "PADDING" | cut -d '"' -f2)
CUSTOM_DIR=$(cat $CONFIG_FILE | grep -E "CUSTOM_DIR" | cut -d '"' -f2)
SEPARATOR=$(cat $CONFIG_FILE | grep -E "SEPARATOR" | cut -d '"' -f2)
PADDING=$(cat $CONFIG_FILE | grep -E "PADDING" | cut -d '"' -f2)
OUTPUT_CACHE="/home/$USER/.config/dwmbar/.cache/"
OUTPUT=""
# What modules, in what order
MODULES=$(cat $CONFIG_NAME | grep -E "MODULES" | cut -d '"' -f2)
MODULES=$(cat $CONFIG_FILE | grep -E "MODULES" | cut -d '"' -f2)
# Modules that require an active internet connection
ONLINE_MODULES=$(cat $CONFIG_NAME | grep -E "ONLINE_MODULES" | cut -d '"' -f2)
ONLINE_MODULES=$(cat $CONFIG_FILE | grep -E "ONLINE_MODULES" | cut -d '"' -f2)
INTERNET=1 #0 being true

18
dwmbar
View file

@ -19,13 +19,15 @@ VERSION="0.1"
DEFAULT_CONFIG_DIR="/usr/share/dwmbar"
DEFAULT_MODULES_DIR="$DEFAULT_CONFIG_DIR/modules"
DEFAULT_RC_LOCATION="$DEFAULT_CONFIG_DIR/dwmbarrc"
DEFAULT_RC_LOCATION="$DEFAULT_CONFIG_DIR/bar.sh"
DEFAULT_CONFIG_LOCATION="$DEFAULT_CONFIG_DIR/config"
RC_LOCATION="/home/$USER/.config/dwmbar/dwmbarrc"
RC_LOCATION="/home/$USER/.config/dwmbar/bar.sh"
CONFIG_DIR="/home/$USER/.config/dwmbar"
MODULES_DIR="$CONFIG_DIR/modules"
CUSTOM_DIR="$MODULES_DIR/custom"
DWMBARRC="$CONFIG_DIR/dwmbarrc"
DWMBARRC="$CONFIG_DIR/bar.sh"
CONFIG_FILE="$CONFIG_DIR/config"
CACHE_DIR="$CONFIG_DIR/.cache"
print_help(){
@ -37,7 +39,8 @@ print_help(){
copy_usr_to_home(){
[[ ! -d $CONFIG_DIR ]] && cp -r /usr/share/dwmbar $CONFIG_DIR
[[ ! -f $DWMBARRC ]] && cp /usr/share/dwmbar/dwmbarrc $DWMBARRC
[[ ! -f $DWMBARRC ]] && cp /usr/share/dwmbar/bar.sh $DWMBARRC
[[ ! -f $CONFIG_FILE ]] && cp /usr/share/dwmbar/config $CONFIG_FILE
[[ ! -d $MODULES_DIR ]] && cp /usr/share/dwmbar/modules $MODULES_DIR
[[ ! -d $CUSTOM_DIR ]] && mkdir $CUSTOM_DIR
[[ ! -d $CACHE_DIR ]] && mkdir $CACHE_DIR
@ -58,9 +61,14 @@ check_files(){
echo "$DEFAULT_RC_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 'v' flag; do
while getopts 'vc' flag; do
case "${flag}" in
v) print_help
exit 0 ;;

View file

@ -28,12 +28,13 @@ if [[ ! -f "dwmbar" ]]; then
fi
# Create /usr/share/dwmbar
# Containing example dwmbarrc and modules
# Containing example bar.sh and modules
mkdir --parents "/usr/share/dwmbar/"
cp -r "./modules" "/usr/share/dwmbar/modules"
cp -r "./dwmbarrc" "/usr/share/dwmbar/dwmbarrc"
cp -r "./bar.sh" "/usr/share/dwmbar/bar.sh"
cp -r "./config" "/usr/share/dwmbar/config"
echo "./dwmbar --> /usr/bin/dwmbar"
cp "./dwmbar" "/usr/bin/dwmbar"