work on bar modules I guess

This commit is contained in:
Daniel Flanagan 2016-12-11 15:17:59 -06:00
parent 554f6dfc79
commit 4f0cba1398
6 changed files with 44 additions and 15 deletions

View file

@ -29,6 +29,10 @@ register_bar_module() {
MODULE_DATA[$1]= MODULE_DATA[$1]=
MODULE_CONTENT[$1]= MODULE_CONTENT[$1]=
MODULE_INIT[$1]=$4 MODULE_INIT[$1]=$4
TYPE_RBM="$(type -t ${MODULE_INIT[$1]})"
TYPE_RBM2="$(type -t ${MODULE_INIT[$3]})"
echo "-----> - $TYPE_RBM - $TYPE_RBM2 -" >> "$BAR_LOG"
${MODULE_INIT[$1]} & ${MODULE_INIT[$1]} &
PID=$! PID=$!
echo $PID > "$BAR_PATH/modules/$3.pid" echo $PID > "$BAR_PATH/modules/$3.pid"
@ -37,19 +41,19 @@ register_bar_module() {
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
# echo -e "$f" >> "$BAR_LOG"
for bl in "$BLACKLISTED_BAR_MODULES"; do for bl in "$BLACKLISTED_BAR_MODULES"; do
if [[ "$f" = "$BAR_PATH/modules/"$bl-bm.bash ]]; then if [[ "$f" = "$BAR_PATH/modules/""${bl}"-bm.bash ]]; then
f="" f=""
fi fi
done done
if [[ -n $f ]]; then if [[ -n $f ]]; then
echo -e "$f" >> "$BAR_LOG"
source "$f" source "$f"
fi 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 # echo ${!MODULE_MATCH[@]} >> $BAR_LOG
if [[ $line == ${MODULE_MATCH[$i]} ]]; then if [[ $line == ${MODULE_MATCH[$i]} ]]; then

27
env/wm/extras/bar/modules/bl.bash vendored Normal file
View file

@ -0,0 +1,27 @@
#!/usr/bin/env bash
source "$DOTFILES_PATH/variables.bash"
PRIORITY=30505
MATCH_PREFIX="BM_BL"
MATCH="$MATCH_PREFIX*"
bar_module_backlight() {
echo -e "%{T-}%{F$COLOR_DARK}lit %{F$COLOR_S5}${1:5}%{F-}"
}
export -f bar_module_backlight
bar_module_backlight_updater() {
while [ $BAR_RUNNING -eq 1 ]; do
# echo -e "$MATCH_PREFIX""$(xbacklight | sed 's/\.[0-9]*//')" > "$BAR_FIFO"
sleep 5
done
}
export -f bar_module_backlight_updater
# Optional: Initialize that module by immediately writing to the FIFO using your
# prefix to show some default information on the bar when it loads.
echo -e "$MATCH_PREFIX"??? > "$BAR_FIFO"
# Register our module so that it is started once the bar is ready
register_bar_module "$PRIORITY" "$MATCH" "bar_module_backlight" "bar_module_backlight_updater"

View file

@ -16,7 +16,7 @@ export -f bar_module_clock
bar_module_clock_updater() { bar_module_clock_updater() {
while true; do while true; do
echo -e "$MATCH_PREFIX""$(date +%H.%M.%S)" > $BAR_FIFO echo -e "$MATCH_PREFIX""$(date +%H.%M.%S)" > "$BAR_FIFO"
sleep 1 sleep 1
done done
} }

View file

@ -15,17 +15,12 @@ MATCH="$MATCH_PREFIX*"
# should process the first argument (the line from the FIFO) and echo the # should process the first argument (the line from the FIFO) and echo the
# desired bar output. # desired bar output.
bar_module_example() { bar_module_example() {
# Write the line from the 10th character (cutting off the MATCH_PREFIX) with # Write the line from the 10th character (cutting off the MATCH_PREFIX)
# lemonbar's left-align delimiter. echo -e "${1:10}"
echo -e "%{l}${1:10}"
} }
# Export our function so that the formatter script can call it. # Export our function so that the formatter script can call it.
export -f bar_module_bspwm export -f bar_module_example
# Call this handy function for adding the various thing we declared to the
# MODULE_ variables that the formatter script uses.
register_bar_module "$PRIORITY" "$MATCH" "bar_module_example"
# Create a function that will periodically write to the FIFO with the correct # Create a function that will periodically write to the FIFO with the correct
# prefix, thereby updating the module. # prefix, thereby updating the module.
@ -35,11 +30,11 @@ bar_module_example_updater() {
sleep 30 sleep 30
done done
} }
export -f bar_module_example_updater
# Fork that function to a background process.
bar_module_clock_updater &
# Optional: Initialize that module by immediately writing to the FIFO using your # Optional: Initialize that module by immediately writing to the FIFO using your
# prefix to show some default information on the bar when it loads. # prefix to show some default information on the bar when it loads.
echo -e "$MATCH_PREFIX"Loading... > "$BAR_FIFO" echo -e "$MATCH_PREFIX"Loading... > "$BAR_FIFO"
# Register our module so that it is started once the bar is ready
register_bar_module "$PRIORITY" "$MATCH" "bar_module_example" "bar_module_example_updater"

0
scripts/monitors.sh Normal file → Executable file
View file

View file

@ -41,6 +41,9 @@ source "$DOTFILES_PATH/env/wm/extras/bar/variables.bash"
# when we kill bspwm we can export the state to this file # when we kill bspwm we can export the state to this file
export BSPWM_STATE_FILE="$DOTFILES_PATH/bspwm_state.json.tmp" export BSPWM_STATE_FILE="$DOTFILES_PATH/bspwm_state.json.tmp"
# disables the clickable launcher buttons for touch or keyboardless devices if 1
export NO_LAUNCHER_BUTTONS=0
# this lets our window gap account for the border width # this lets our window gap account for the border width
# if this is enabled, it is usually so that I can reduce border width on my # if this is enabled, it is usually so that I can reduce border width on my
# desktops with a single chrome window on them so that I can click that tabs at # desktops with a single chrome window on them so that I can click that tabs at