From db377935940948f1b61a3194a922265c47ac69ef Mon Sep 17 00:00:00 2001 From: Manuel Palenzuela Date: Thu, 24 Oct 2019 14:46:11 +0100 Subject: [PATCH 1/8] Added different config file --- dwmbarrc | 14 ++++++++------ modulesrc | 17 +++++++++++++++++ 2 files changed, 25 insertions(+), 6 deletions(-) create mode 100644 modulesrc diff --git a/dwmbarrc b/dwmbarrc index cfe6c6f..02b9a01 100755 --- a/dwmbarrc +++ b/dwmbarrc @@ -15,20 +15,22 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -DELAY=0.05 +CONFIG_NAME="modulesrc" + +DELAY=$(cat $CONFIG_NAME | grep -E "DELAY" | cut -d '"' -f2) MODULES_DIR="/home/$USER/.config/dwmbar/modules/" -CUSTOM_DIR="/home/$USER/.config/dwmbar/modules/custom/" -SEPARATOR=" | " -PADDING="$USER@$HOSTNAME " +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) OUTPUT_CACHE="/home/$USER/.config/dwmbar/.cache/" OUTPUT="" # What modules, in what order -MODULES="mpd weather volumebar wifi internet cpuload temperature battery date time" +MODULES=$(cat $CONFIG_NAME | grep -E "MODULES" | cut -d '"' -f2) # Modules that require an active internet connection -ONLINE_MODULES="weather internet" +ONLINE_MODULES=$(cat $CONFIG_NAME | grep -E "ONLINE_MODULES" | cut -d '"' -f2) INTERNET=1 #0 being true diff --git a/modulesrc b/modulesrc new file mode 100644 index 0000000..eab201c --- /dev/null +++ b/modulesrc @@ -0,0 +1,17 @@ +# What modules, in what order +MODULES="mpd weather volumebar wifi internet cpuload temperatu + +# Modules that require an active internet connection +ONLINE_MODULES="weather internet" + +# Delay between showing the status bar +DELAY="0.05" + +# Where the custom modules are stored +CUSTOM_DIR="/home/$USER/.config/dwmbar/modules/custom/" + +# Separator between modules +SEPARATOR=" | " + +# Padding at the end and beggining of the status bar +PADDING="$USER@$HOSTNAME " From 2808138791d1859a692d1902df81ad9ffb25b6d1 Mon Sep 17 00:00:00 2001 From: Manuel Palenzuela Date: Thu, 24 Oct 2019 14:48:04 +0100 Subject: [PATCH 2/8] Changed names of files --- dwmbarrc => bar.sh | 0 modulesrc => config | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename dwmbarrc => bar.sh (100%) rename modulesrc => config (100%) diff --git a/dwmbarrc b/bar.sh similarity index 100% rename from dwmbarrc rename to bar.sh diff --git a/modulesrc b/config similarity index 100% rename from modulesrc rename to config From 63d1282294a6226e9dba2d5868c756376ca99ab2 Mon Sep 17 00:00:00 2001 From: Manuel Palenzuela Date: Thu, 24 Oct 2019 15:13:38 +0100 Subject: [PATCH 3/8] Changed names of files part 2 --- bar.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bar.sh b/bar.sh index 02b9a01..88455ae 100755 --- a/bar.sh +++ b/bar.sh @@ -15,7 +15,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -CONFIG_NAME="modulesrc" +CONFIG_NAME="config" DELAY=$(cat $CONFIG_NAME | grep -E "DELAY" | cut -d '"' -f2) MODULES_DIR="/home/$USER/.config/dwmbar/modules/" From ac73412ccbdd3235d3943f18bce6931f2ce4324c Mon Sep 17 00:00:00 2001 From: Manuel Palenzuela Date: Thu, 24 Oct 2019 15:31:03 +0100 Subject: [PATCH 4/8] Implemented different config file --- TODO.org | 5 +++++ bar.sh | 14 +++++++------- dwmbar | 18 +++++++++++++----- install.sh | 5 +++-- 4 files changed, 28 insertions(+), 14 deletions(-) diff --git a/TODO.org b/TODO.org index 07316d0..9d5d61e 100644 --- a/TODO.org +++ b/TODO.org @@ -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 diff --git a/bar.sh b/bar.sh index 88455ae..c56cfa1 100755 --- a/bar.sh +++ b/bar.sh @@ -15,22 +15,22 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -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 diff --git a/dwmbar b/dwmbar index a4d3c38..f0514c7 100755 --- a/dwmbar +++ b/dwmbar @@ -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 ;; diff --git a/install.sh b/install.sh index 84f6a3e..715c989 100755 --- a/install.sh +++ b/install.sh @@ -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" From 4d1c3a91f7811732af65a7a0ac7d477f2a2a497b Mon Sep 17 00:00:00 2001 From: "Archie Hilton (thytom)" Date: Thu, 24 Oct 2019 16:30:51 +0100 Subject: [PATCH 5/8] Fixed the config --- config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config b/config index eab201c..ce46b0e 100644 --- a/config +++ b/config @@ -1,5 +1,5 @@ # What modules, in what order -MODULES="mpd weather volumebar wifi internet cpuload temperatu +MODULES="mpd weather volumebar wifi internet cpuload temperature" # Modules that require an active internet connection ONLINE_MODULES="weather internet" From b4fb27fd60a64c608319c97826ec2f09f5c26732 Mon Sep 17 00:00:00 2001 From: "Archie Hilton (thytom)" Date: Thu, 24 Oct 2019 16:50:31 +0100 Subject: [PATCH 6/8] Just use the source command, and added left padding. --- TODO.org | 1 - bar.sh | 15 +++------------ config | 9 +++++++-- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/TODO.org b/TODO.org index 9d5d61e..0646d1d 100644 --- a/TODO.org +++ b/TODO.org @@ -17,7 +17,6 @@ Each module writes to stdout. - 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 diff --git a/bar.sh b/bar.sh index c56cfa1..44c4ec0 100755 --- a/bar.sh +++ b/bar.sh @@ -15,23 +15,14 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . + CONFIG_FILE="/home/$USER/.config/dwmbar/config" -DELAY=$(cat $CONFIG_FILE | grep -E "DELAY" | cut -d '"' -f2) -MODULES_DIR="/home/$USER/.config/dwmbar/modules/" -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) +source $CONFIG_FILE OUTPUT_CACHE="/home/$USER/.config/dwmbar/.cache/" OUTPUT="" -# What modules, in what order -MODULES=$(cat $CONFIG_FILE | grep -E "MODULES" | cut -d '"' -f2) - -# Modules that require an active internet connection -ONLINE_MODULES=$(cat $CONFIG_FILE | grep -E "ONLINE_MODULES" | cut -d '"' -f2) - INTERNET=1 #0 being true get_internet() @@ -55,7 +46,7 @@ get_bar() done # Uncomment to remove last separator # bar=$(echo $bar | sed 's/.$//g') - echo "$bar$PADDING" + echo "$LEFT_PADDING$bar$RIGHT_PADDING" } run_module() diff --git a/config b/config index ce46b0e..503b487 100644 --- a/config +++ b/config @@ -1,5 +1,9 @@ +#!/bin/bash + +MODULES_DIR="/home/$USER/.config/dwmbar/modules/" + # What modules, in what order -MODULES="mpd weather volumebar wifi internet cpuload temperature" +MODULES="mpd weather volumebar wifi internet cpuload temperature date time" # Modules that require an active internet connection ONLINE_MODULES="weather internet" @@ -14,4 +18,5 @@ CUSTOM_DIR="/home/$USER/.config/dwmbar/modules/custom/" SEPARATOR=" | " # Padding at the end and beggining of the status bar -PADDING="$USER@$HOSTNAME " +RIGHT_PADDING="$USER@$HOSTNAME " +LEFT_PADDING=" " From 64300140a1a59b30dabc577eea7e26ffc8f3b4a8 Mon Sep 17 00:00:00 2001 From: "Archie Hilton (thytom)" Date: Thu, 24 Oct 2019 17:27:20 +0100 Subject: [PATCH 7/8] Restructuring Moved bar.sh to /usr/share/dwmbar. Modules are now only in /usr/share/dwmbar. Custom modules folder is now in .config/dwmbar. This will allow for paralellised modules down the line. --- bar.sh | 7 ++++--- config | 2 -- dwmbar | 15 +++++---------- install.sh | 7 ++++++- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/bar.sh b/bar.sh index 44c4ec0..f9866f4 100755 --- a/bar.sh +++ b/bar.sh @@ -16,13 +16,14 @@ # along with this program. If not, see . -CONFIG_FILE="/home/$USER/.config/dwmbar/config" - -source $CONFIG_FILE +MODULES_DIR="/usr/share/dwmbar/modules/" OUTPUT_CACHE="/home/$USER/.config/dwmbar/.cache/" OUTPUT="" +CONFIG_FILE="/home/$USER/.config/dwmbar/config" +source $CONFIG_FILE + INTERNET=1 #0 being true get_internet() diff --git a/config b/config index 503b487..c53aaeb 100644 --- a/config +++ b/config @@ -1,7 +1,5 @@ #!/bin/bash -MODULES_DIR="/home/$USER/.config/dwmbar/modules/" - # What modules, in what order MODULES="mpd weather volumebar wifi internet cpuload temperature date time" diff --git a/dwmbar b/dwmbar index f0514c7..2536d13 100755 --- a/dwmbar +++ b/dwmbar @@ -19,14 +19,11 @@ VERSION="0.1" DEFAULT_CONFIG_DIR="/usr/share/dwmbar" DEFAULT_MODULES_DIR="$DEFAULT_CONFIG_DIR/modules" -DEFAULT_RC_LOCATION="$DEFAULT_CONFIG_DIR/bar.sh" +DEFAULT_BAR_LOCATION="$DEFAULT_CONFIG_DIR/bar.sh" DEFAULT_CONFIG_LOCATION="$DEFAULT_CONFIG_DIR/config" -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/bar.sh" +CUSTOM_DIR="$CONFIG_DIR/custom" CONFIG_FILE="$CONFIG_DIR/config" CACHE_DIR="$CONFIG_DIR/.cache" @@ -39,9 +36,7 @@ print_help(){ copy_usr_to_home(){ [[ ! -d $CONFIG_DIR ]] && cp -r /usr/share/dwmbar $CONFIG_DIR - [[ ! -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 } @@ -57,8 +52,8 @@ check_files(){ exit 1 fi - if [[ ! -f $DEFAULT_RC_LOCATION ]]; then - echo "$DEFAULT_RC_LOCATION does not exist." > /dev/stderr + if [[ ! -f $DEFAULT_BAR_LOCATION ]]; then + echo "$DEFAULT_BAR_LOCATION does not exist." > /dev/stderr exit 1 fi @@ -80,5 +75,5 @@ done check_files while :; do - xsetroot -name "$(exec $RC_LOCATION)" + xsetroot -name "$(exec $DEFAULT_BAR_LOCATION)" done diff --git a/install.sh b/install.sh index 715c989..c409bd2 100755 --- a/install.sh +++ b/install.sh @@ -32,8 +32,13 @@ fi mkdir --parents "/usr/share/dwmbar/" +echo "./modules --> /usr/share/dwmbar/modules" cp -r "./modules" "/usr/share/dwmbar/modules" -cp -r "./bar.sh" "/usr/share/dwmbar/bar.sh" + +echo "./bar.sh --> /usr/share/dwmbar/bar.sh" +cp "./bar.sh" "/usr/share/dwmbar/bar.sh" + +echo "./config --> /usr/share/dwmbar/config" cp -r "./config" "/usr/share/dwmbar/config" echo "./dwmbar --> /usr/bin/dwmbar" From 2d2c78a6d7472081fe9af181fd5e75fb7069d9e6 Mon Sep 17 00:00:00 2001 From: "Archie Hilton (thytom)" Date: Thu, 24 Oct 2019 17:34:14 +0100 Subject: [PATCH 8/8] Updated version number --- dwmbar | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dwmbar b/dwmbar index 2536d13..62c26ee 100755 --- a/dwmbar +++ b/dwmbar @@ -15,7 +15,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -VERSION="0.1" +VERSION="0.2" DEFAULT_CONFIG_DIR="/usr/share/dwmbar" DEFAULT_MODULES_DIR="$DEFAULT_CONFIG_DIR/modules"