fully functional and modular bar <3
This commit is contained in:
parent
b4a5567341
commit
48fe7dee23
|
@ -3,8 +3,8 @@
|
||||||
source "$DOTFILES_PATH/variables.bash"
|
source "$DOTFILES_PATH/variables.bash"
|
||||||
source "$DOTFILES_PATH/wm/extras/bar/colors.bash"
|
source "$DOTFILES_PATH/wm/extras/bar/colors.bash"
|
||||||
|
|
||||||
export BAR_LOG="$PWD/bar.log"
|
# export BAR_LOG="$PWD/bar.log"
|
||||||
echo -e "BEGIN BAR LOG\n" > "$BAR_LOG"
|
# echo -e "BEGIN BAR LOG\n" > "$BAR_LOG"
|
||||||
|
|
||||||
export MODULE_MATCH=()
|
export MODULE_MATCH=()
|
||||||
export MODULE_CALLBACK=()
|
export MODULE_CALLBACK=()
|
||||||
|
@ -16,7 +16,7 @@ register_bar_module() {
|
||||||
MODULE_CALLBACK[$1]=$3
|
MODULE_CALLBACK[$1]=$3
|
||||||
MODULE_DATA[$1]=
|
MODULE_DATA[$1]=
|
||||||
MODULE_CONTENT[$1]=
|
MODULE_CONTENT[$1]=
|
||||||
echo -e "Registered Bar Module: $1 $2 $3" >> "$BAR_LOG"
|
# echo -e "Registered Bar Module: $1 $2 $3" >> "$BAR_LOG"
|
||||||
}
|
}
|
||||||
export -f register_bar_module
|
export -f register_bar_module
|
||||||
|
|
||||||
|
@ -25,12 +25,12 @@ for f in "$DOTFILES_PATH/wm/extras/bar/modules/"*-bm.bash; do
|
||||||
done
|
done
|
||||||
|
|
||||||
while read -r line; do
|
while read -r line; do
|
||||||
echo -e "Bar Line: $line" >> "$BAR_LOG"
|
# echo -e "Bar Line: $line" >> "$BAR_LOG"
|
||||||
for i in ${!MODULE_MATCH[@]}; do
|
for i in ${!MODULE_MATCH[@]}; do
|
||||||
if [[ $line == ${MODULE_MATCH[$i]} ]]; then
|
if [[ $line == ${MODULE_MATCH[$i]} ]]; then
|
||||||
echo -e "Bar Module Update: [$i] Matched ${MODULE_MATCH[$i]} with $line" >> "$BAR_LOG"
|
# echo -e "Bar Module Update: [$i] Matched ${MODULE_MATCH[$i]} with $line" >> "$BAR_LOG"
|
||||||
MODULE_CONTENT[$i]=$("${MODULE_CALLBACK[$i]}" $line)
|
MODULE_CONTENT[$i]="$("${MODULE_CALLBACK[$i]}" "$line")"
|
||||||
echo -e "New Module Content: "${MODULE_CONTENT[$i]} >> "$BAR_LOG"
|
# echo -e "New Module Content: "${MODULE_CONTENT[$i]} >> "$BAR_LOG"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -38,18 +38,17 @@ while read -r line; do
|
||||||
c_content=""
|
c_content=""
|
||||||
r_content=""
|
r_content=""
|
||||||
for i in ${!MODULE_CONTENT[@]}; do
|
for i in ${!MODULE_CONTENT[@]}; do
|
||||||
echo -e "Processing Module $i Content..." >> "$BAR_LOG"
|
|
||||||
if [ $i -ge 30000 ]; then
|
if [ $i -ge 30000 ]; then
|
||||||
r_content="$content ${MODULE_CONTENT[$i]}"
|
r_content="$r_content ${MODULE_CONTENT[$i]}"
|
||||||
elif [ $i -ge 20000 ]; then
|
elif [ $i -ge 20000 ]; then
|
||||||
c_content="$content ${MODULE_CONTENT[$i]}"
|
c_content="$c_content ${MODULE_CONTENT[$i]}"
|
||||||
else
|
else
|
||||||
l_content="$content ${MODULE_CONTENT[$i]}"
|
l_content="$l_content ${MODULE_CONTENT[$i]}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
printf " %s \n" "%{l}$l_content %{c}$c_content %{r}$r_content"
|
printf " %s \n" "%{l}$l_content %{c}$c_content %{r}$r_content"
|
||||||
done
|
done
|
||||||
|
|
||||||
echo -e "\nEND BAR LOG" >> "$BAR_LOG"
|
# echo -e "\nEND BAR LOG" >> "$BAR_LOG"
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,7 @@ MATCH_PREFIX="BM_DATE"
|
||||||
MATCH="$MATCH_PREFIX*"
|
MATCH="$MATCH_PREFIX*"
|
||||||
|
|
||||||
bar_module_date() {
|
bar_module_date() {
|
||||||
echo -e "$1 "
|
echo -e "%{T-}%{r}%{F$COLOR_S2}${1:7}%{F-}"
|
||||||
# echo -e "%{T-}%{r}%{F$COLOR_S2}${1:7}%{F-}"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export -f bar_module_date
|
export -f bar_module_date
|
||||||
|
@ -19,7 +18,7 @@ register_bar_module "$PRIORITY" "$MATCH" "bar_module_date"
|
||||||
bar_module_date_updater() {
|
bar_module_date_updater() {
|
||||||
while true; do
|
while true; do
|
||||||
echo -e "$MATCH_PREFIX""$(date +'%a %b %d')" > $BAR_FIFO
|
echo -e "$MATCH_PREFIX""$(date +'%a %b %d')" > $BAR_FIFO
|
||||||
sleep 1
|
sleep 60
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
bar_module_date_updater &
|
bar_module_date_updater &
|
||||||
|
|
|
@ -3,23 +3,25 @@
|
||||||
source "$DOTFILES_PATH/variables.bash"
|
source "$DOTFILES_PATH/variables.bash"
|
||||||
source "$DOTFILES_PATH/wm/extras/bar/colors.bash"
|
source "$DOTFILES_PATH/wm/extras/bar/colors.bash"
|
||||||
|
|
||||||
PRIORITY=38000
|
PRIORITY=12000
|
||||||
|
|
||||||
MATCH_PREFIX="BM_CLOCK"
|
MATCH_PREFIX="BM_PACAUR"
|
||||||
MATCH="$MATCH_PREFIX*"
|
MATCH="$MATCH_PREFIX*"
|
||||||
|
|
||||||
bar_module_clock() {
|
bar_module_pacaur() {
|
||||||
echo -e "%{T-}%{F$COLOR_S1}${1:8}%{F-}"
|
echo -e "%{T-}%{F$COLOR_DARK}pac %{F$COLOR_S1}${1:9}%{F-}"
|
||||||
}
|
}
|
||||||
|
|
||||||
export -f bar_module_clock
|
export -f bar_module_pacaur
|
||||||
register_bar_module "$PRIORITY" "$MATCH" "bar_module_clock"
|
register_bar_module "$PRIORITY" "$MATCH" "bar_module_pacaur"
|
||||||
|
|
||||||
bar_module_clock_updater() {
|
bar_module_pacaur_updater() {
|
||||||
while true; do
|
while true; do
|
||||||
echo -e "$MATCH_PREFIX""$(date +%H.%M.%S)" > $BAR_FIFO
|
NUM_PACKAGES=$(pacaur -Syq > /dev/null && pacaur -Qqu | wc -l)
|
||||||
sleep 1
|
echo -e "$MATCH_PREFIX""$NUM_PACKAGES" > "$BAR_FIFO"
|
||||||
|
sleep 300
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
bar_module_clock_updater &
|
bar_module_pacaur_updater &
|
||||||
|
|
||||||
|
echo -e "$MATCH_PREFIX"?? > "$BAR_FIFO"
|
||||||
|
|
Reference in a new issue