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]} &
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
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
while read -r line; do
# echo -e "Bar Line: $line" >> "$BAR_LOG"
for i in ${!MODULE_MATCH[@]}; do
echo ${!MODULE_MATCH[@]} >> $BAR_LOG
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")"
# echo -e "New Module Content: "${MODULE_CONTENT[$i]} >> "$BAR_LOG"
fi
@ -52,13 +61,13 @@ while read -r line; do
if [ $i -ge 30000 ]; then
r_content="$r_content ${MODULE_CONTENT[$i]}"
elif [ $i -ge 20000 ]; then
c_content="$c_content ${MODULE_CONTENT[$i]}"
c_content="$c_content${MODULE_CONTENT[$i]} "
else
l_content="$l_content ${MODULE_CONTENT[$i]}"
l_content="$l_content${MODULE_CONTENT[$i]} "
fi
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
# 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 "$BAR_PATH/colors.bash"
PRIORITY=25000
PRIORITY=15000
PID_PREFIX="bspwm"
MATCH_PREFIX="W"
MATCH="$MATCH_PREFIX*"
DESKTOP_SPACER=" "
ul="u"
if [ $BAR_UNDERLINE -eq 1 ]; then
:
@ -17,7 +19,7 @@ else
fi
bar_module_bspwm() {
content="%{F$COLOR_FOREGROUND}%{c}"
content="%{F$COLOR_FOREGROUND}"
line=$1
IFS=':'
set -- ${line#?}
@ -27,22 +29,22 @@ bar_module_bspwm() {
cname="$name"
case $item in
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
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
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
content="${content} %{F$COLOR_FOREGROUND}${cname}%{F-}"
content="${content}%{F$COLOR_FOREGROUND}${cname}%{F-}$DESKTOP_SPACER"
;;
f*) # free desktop
content="${content} %{F$COLOR_DARK}${cname}%{F-}"
content="${content}%{F$COLOR_DARK}${cname}%{F-}$DESKTOP_SPACER"
;;
u*) # urgent desktop
content="${content} %{F$COLOR_URGENT}${cname}%{F-}"
content="${content}%{F$COLOR_URGENT}${cname}%{F-}$DESKTOP_SPACER"
;;
esac
shift

View file

@ -9,7 +9,7 @@ MATCH_PREFIX="BM_DATE"
MATCH="$MATCH_PREFIX*"
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

View file

@ -3,13 +3,13 @@
source "$DOTFILES_PATH/variables.bash"
source "$BAR_PATH/colors.bash"
PRIORITY=12000
PRIORITY=32000
MATCH_PREFIX="BM_PACAUR"
MATCH="$MATCH_PREFIX*"
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

View file

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