mirror of
https://git.adityakumar.xyz/dwmbar.git
synced 2024-11-09 22:19:45 +00:00
Implemented different config file
This commit is contained in:
parent
63d1282294
commit
ac73412ccb
4 changed files with 28 additions and 14 deletions
5
TODO.org
5
TODO.org
|
@ -13,6 +13,11 @@ Each module writes to stdout.
|
||||||
- Different file for customizable stuff
|
- Different file for customizable stuff
|
||||||
- dwmbar uses /usr/bin/dwmbarrc if no .config/dwmbar/dwmbarrc exists.
|
- dwmbar uses /usr/bin/dwmbarrc if no .config/dwmbar/dwmbarrc exists.
|
||||||
- Delay in archupdates module (if minutes divisible by 5/4)
|
- 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:
|
Bugs to fix:
|
||||||
None
|
None
|
||||||
|
|
14
bar.sh
14
bar.sh
|
@ -15,22 +15,22 @@
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
# 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/"
|
MODULES_DIR="/home/$USER/.config/dwmbar/modules/"
|
||||||
CUSTOM_DIR=$(cat $CONFIG_NAME | grep -E "CUSTOM_DIR" | cut -d '"' -f2)
|
CUSTOM_DIR=$(cat $CONFIG_FILE | grep -E "CUSTOM_DIR" | cut -d '"' -f2)
|
||||||
SEPARATOR=$(cat $CONFIG_NAME | grep -E "SEPARATOR" | cut -d '"' -f2)
|
SEPARATOR=$(cat $CONFIG_FILE | grep -E "SEPARATOR" | cut -d '"' -f2)
|
||||||
PADDING=$(cat $CONFIG_NAME | grep -E "PADDING" | cut -d '"' -f2)
|
PADDING=$(cat $CONFIG_FILE | grep -E "PADDING" | cut -d '"' -f2)
|
||||||
|
|
||||||
OUTPUT_CACHE="/home/$USER/.config/dwmbar/.cache/"
|
OUTPUT_CACHE="/home/$USER/.config/dwmbar/.cache/"
|
||||||
OUTPUT=""
|
OUTPUT=""
|
||||||
|
|
||||||
# What modules, in what order
|
# 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
|
# 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
|
INTERNET=1 #0 being true
|
||||||
|
|
||||||
|
|
18
dwmbar
18
dwmbar
|
@ -19,13 +19,15 @@ VERSION="0.1"
|
||||||
|
|
||||||
DEFAULT_CONFIG_DIR="/usr/share/dwmbar"
|
DEFAULT_CONFIG_DIR="/usr/share/dwmbar"
|
||||||
DEFAULT_MODULES_DIR="$DEFAULT_CONFIG_DIR/modules"
|
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"
|
CONFIG_DIR="/home/$USER/.config/dwmbar"
|
||||||
MODULES_DIR="$CONFIG_DIR/modules"
|
MODULES_DIR="$CONFIG_DIR/modules"
|
||||||
CUSTOM_DIR="$MODULES_DIR/custom"
|
CUSTOM_DIR="$MODULES_DIR/custom"
|
||||||
DWMBARRC="$CONFIG_DIR/dwmbarrc"
|
DWMBARRC="$CONFIG_DIR/bar.sh"
|
||||||
|
CONFIG_FILE="$CONFIG_DIR/config"
|
||||||
CACHE_DIR="$CONFIG_DIR/.cache"
|
CACHE_DIR="$CONFIG_DIR/.cache"
|
||||||
|
|
||||||
print_help(){
|
print_help(){
|
||||||
|
@ -37,7 +39,8 @@ print_help(){
|
||||||
|
|
||||||
copy_usr_to_home(){
|
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 $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 $MODULES_DIR ]] && cp /usr/share/dwmbar/modules $MODULES_DIR
|
||||||
[[ ! -d $CUSTOM_DIR ]] && mkdir $CUSTOM_DIR
|
[[ ! -d $CUSTOM_DIR ]] && mkdir $CUSTOM_DIR
|
||||||
[[ ! -d $CACHE_DIR ]] && mkdir $CACHE_DIR
|
[[ ! -d $CACHE_DIR ]] && mkdir $CACHE_DIR
|
||||||
|
@ -58,9 +61,14 @@ check_files(){
|
||||||
echo "$DEFAULT_RC_LOCATION does not exist." > /dev/stderr
|
echo "$DEFAULT_RC_LOCATION does not exist." > /dev/stderr
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
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
|
case "${flag}" in
|
||||||
v) print_help
|
v) print_help
|
||||||
exit 0 ;;
|
exit 0 ;;
|
||||||
|
|
|
@ -28,12 +28,13 @@ if [[ ! -f "dwmbar" ]]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create /usr/share/dwmbar
|
# Create /usr/share/dwmbar
|
||||||
# Containing example dwmbarrc and modules
|
# Containing example bar.sh and modules
|
||||||
|
|
||||||
mkdir --parents "/usr/share/dwmbar/"
|
mkdir --parents "/usr/share/dwmbar/"
|
||||||
|
|
||||||
cp -r "./modules" "/usr/share/dwmbar/modules"
|
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"
|
echo "./dwmbar --> /usr/bin/dwmbar"
|
||||||
cp "./dwmbar" "/usr/bin/dwmbar"
|
cp "./dwmbar" "/usr/bin/dwmbar"
|
||||||
|
|
Loading…
Reference in a new issue