added battery bar module, fixed some bugs

This commit is contained in:
Daniel Flanagan 2016-09-02 21:14:45 -05:00
parent 3fad011938
commit dfc9b36efe
6 changed files with 56 additions and 17 deletions

View file

@ -27,19 +27,28 @@ register_bar_module() {
${MODULE_INIT[$1]} & ${MODULE_INIT[$1]} &
PID=$! PID=$!
echo $PID > "$BAR_PATH/modules/$3.pid" echo $PID > "$BAR_PATH/modules/$3.pid"
# echo -e "Registered Bar Module: $1 $2 $3 $4 with PID $PID" >> "$BAR_LOG" echo -e "Registered Bar Module: $1 $2 $3 $4 with PID $PID" >> "$BAR_LOG"
} }
export -f register_bar_module export -f register_bar_module
for f in "$BAR_PATH/modules/"*-bm.bash; do for f in "$BAR_PATH/modules/"*-bm.bash; do
source "$f" echo -e "$f" >> "$BAR_LOG"
for bl in "$BLACKLISTED_BAR_MODULES"; do
if [[ "$f" = "$BAR_PATH/modules/"$bl-bm.bash ]]; then
f=""
fi
done
if [[ -n $f ]]; then
source "$f"
fi
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
echo ${!MODULE_MATCH[@]} >> $BAR_LOG
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
@ -52,13 +61,13 @@ while read -r line; do
if [ $i -ge 30000 ]; then if [ $i -ge 30000 ]; then
r_content="$r_content ${MODULE_CONTENT[$i]}" r_content="$r_content ${MODULE_CONTENT[$i]}"
elif [ $i -ge 20000 ]; then elif [ $i -ge 20000 ]; then
c_content="$c_content ${MODULE_CONTENT[$i]}" c_content="$c_content${MODULE_CONTENT[$i]} "
else else
l_content="$l_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"

View file

@ -0,0 +1,27 @@
#!/usr/bin/env bash
source "$DOTFILES_PATH/variables.bash"
source "$BAR_PATH/colors.bash"
PRIORITY=31000
MATCH_PREFIX="BM_BATTERY"
MATCH="$MATCH_PREFIX*"
bar_module_battery() {
echo -e "%{T-}%{F$COLOR_DARK}bat %{F$COLOR_S3}${1:10}%{F-}"
}
export -f bar_module_battery
bar_module_battery_updater() {
while true; do
echo -e "$MATCH_PREFIX""$(cat /sys/class/power_supply/BAT*/capacity)" > $BAR_FIFO
sleep 60
done
}
export -f bar_module_battery_updater
TYPE_RBM="$(type -t register_bar_module)"
if [[ -n "$TYPE_RBM" ]] && [[ "$TYPE_RBM" = function ]]; then
register_bar_module "$PRIORITY" "$MATCH" "bar_module_battery" "bar_module_battery_updater"
fi

View file

@ -3,12 +3,14 @@
source "$DOTFILES_PATH/variables.bash" source "$DOTFILES_PATH/variables.bash"
source "$BAR_PATH/colors.bash" source "$BAR_PATH/colors.bash"
PRIORITY=25000 PRIORITY=15000
PID_PREFIX="bspwm" PID_PREFIX="bspwm"
MATCH_PREFIX="W" MATCH_PREFIX="W"
MATCH="$MATCH_PREFIX*" MATCH="$MATCH_PREFIX*"
DESKTOP_SPACER=" "
ul="u" ul="u"
if [ $BAR_UNDERLINE -eq 1 ]; then if [ $BAR_UNDERLINE -eq 1 ]; then
: :
@ -17,7 +19,7 @@ else
fi fi
bar_module_bspwm() { bar_module_bspwm() {
content="%{F$COLOR_FOREGROUND}%{c}" content="%{F$COLOR_FOREGROUND}"
line=$1 line=$1
IFS=':' IFS=':'
set -- ${line#?} set -- ${line#?}
@ -27,22 +29,22 @@ bar_module_bspwm() {
cname="$name" cname="$name"
case $item in case $item in
O*) # focused occupied desktop O*) # focused occupied desktop
content="${content} %{F$COLOR_HIGHLIGHT}%{U$COLOR_HIGHLIGHT}%{+${ul}}${cname}%{-${ul}}%{U-}%{F-}" content="${content}%{F$COLOR_HIGHLIGHT}%{U$COLOR_HIGHLIGHT}%{+${ul}}${cname}%{-${ul}}%{U-}%{F-}$DESKTOP_SPACER"
;; ;;
F*) # focused free desktop F*) # focused free desktop
content="${content} %{F$COLOR_DARK}%{U$COLOR_DARK}%{+${ul}}${cname}%{-${ul}}%{U-}%{F-}" content="${content}%{F$COLOR_DARK}%{U$COLOR_DARK}%{+${ul}}${cname}%{-${ul}}%{U-}%{F-}$DESKTOP_SPACER"
;; ;;
U*) # focused occupied desktop U*) # focused occupied desktop
content="${content} %{F$COLOR_URGENT}%{U$COLOR_URGENT}%{+${ul}}${cname}%{-${ul}}%{U-}%{F-}" content="${content}%{F$COLOR_URGENT}%{U$COLOR_URGENT}%{+${ul}}${cname}%{-${ul}}%{U-}%{F-}$DESKTOP_SPACER"
;; ;;
o*) # occupied desktop o*) # occupied desktop
content="${content} %{F$COLOR_FOREGROUND}${cname}%{F-}" content="${content}%{F$COLOR_FOREGROUND}${cname}%{F-}$DESKTOP_SPACER"
;; ;;
f*) # free desktop f*) # free desktop
content="${content} %{F$COLOR_DARK}${cname}%{F-}" content="${content}%{F$COLOR_DARK}${cname}%{F-}$DESKTOP_SPACER"
;; ;;
u*) # urgent desktop u*) # urgent desktop
content="${content} %{F$COLOR_URGENT}${cname}%{F-}" content="${content}%{F$COLOR_URGENT}${cname}%{F-}$DESKTOP_SPACER"
;; ;;
esac esac
shift shift

View file

@ -9,7 +9,7 @@ MATCH_PREFIX="BM_DATE"
MATCH="$MATCH_PREFIX*" MATCH="$MATCH_PREFIX*"
bar_module_date() { bar_module_date() {
echo -e "%{T-}%{r}%{F$COLOR_S2}${1:7}%{F-}" echo -e "%{F$COLOR_DARK}| %{T-}%{F$COLOR_S2}${1:7}%{F-}"
} }
export -f bar_module_date export -f bar_module_date

View file

@ -3,13 +3,13 @@
source "$DOTFILES_PATH/variables.bash" source "$DOTFILES_PATH/variables.bash"
source "$BAR_PATH/colors.bash" source "$BAR_PATH/colors.bash"
PRIORITY=12000 PRIORITY=32000
MATCH_PREFIX="BM_PACAUR" MATCH_PREFIX="BM_PACAUR"
MATCH="$MATCH_PREFIX*" MATCH="$MATCH_PREFIX*"
bar_module_pacaur() { bar_module_pacaur() {
echo -e "%{T-}%{F$COLOR_DARK}pac %{F$COLOR_S1}${1:9}%{F-}" echo -e "%{T-}%{F$COLOR_DARK}pac %{F$COLOR_S4}${1:9}%{F-}"
} }
export -f bar_module_pacaur export -f bar_module_pacaur

View file

@ -4,6 +4,7 @@
# each of the scripts that will be executed in those process. # each of the scripts that will be executed in those process.
export DOTFILES_PATH="$HOME/.dotfiles" export DOTFILES_PATH="$HOME/.dotfiles"
export BLACKLISTED_BAR_MODULES=""
export REPOSITORY_PATH="$HOME/../code/open-source" export REPOSITORY_PATH="$HOME/../code/open-source"
export BORDER_WIDTH=1 export BORDER_WIDTH=1
export WINDOW_GAP=5 export WINDOW_GAP=5