aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xdwmbar41
-rwxr-xr-xinstall.sh5
2 files changed, 40 insertions, 6 deletions
diff --git a/dwmbar b/dwmbar
index 00e4aa9..adf2882 100755
--- a/dwmbar
+++ b/dwmbar
@@ -1,5 +1,9 @@
#!/bin/bash
-VERSION="0.0.1"
+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"
@@ -9,10 +13,13 @@ DWMBARRC="$CONFIG_DIR/dwmbarrc"
CACHE_DIR="$CONFIG_DIR/.cache"
print_help(){
- echo "dwmbar $VERSION"
+ echo "dwmbar $VERSION
+-v Display this help message.
+-c Copy default files to /home/$USER/.config/dwmbar
+"
}
-install_files(){
+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
@@ -20,7 +27,33 @@ install_files(){
[[ ! -d $CACHE_DIR ]] && mkdir $CACHE_DIR
}
-install_files
+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)"
diff --git a/install.sh b/install.sh
index c110d3d..a77009f 100755
--- a/install.sh
+++ b/install.sh
@@ -3,12 +3,13 @@
DWMBAR="/usr/bin/dwmbar"
if [ "$EUID" -ne 0 ]
- then echo "Please run as root"
+ then echo "Please run as root" > /dev/stderr
exit 1
fi
if [[ ! -f "dwmbar" ]]; then
- echo "dwmbar executable not found."
+ echo "dwmbar executable not found." > /dev/stderr
+ exit 1
fi
# Create /usr/share/dwmbar