2016-01-11 09:22:54 -06:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
source "$DOTFILES_PATH/variables.bash"
|
|
|
|
|
2016-01-12 15:41:12 -06:00
|
|
|
# export BAR_LOG="$PWD/bar.log"
|
|
|
|
# echo -e "BEGIN BAR LOG\n" > "$BAR_LOG"
|
2016-01-12 15:02:12 -06:00
|
|
|
|
2016-07-15 12:17:12 -05:00
|
|
|
reload_colors() {
|
2016-07-29 11:20:11 -05:00
|
|
|
source "$BAR_PATH/colors.bash"
|
2016-07-15 12:17:12 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
# trap reload_colors SIGUSR1
|
|
|
|
|
2016-01-12 15:02:12 -06:00
|
|
|
export MODULE_MATCH=()
|
|
|
|
export MODULE_CALLBACK=()
|
|
|
|
export MODULE_DATA=()
|
|
|
|
export MODULE_CONTENT=()
|
2016-07-27 08:57:56 -05:00
|
|
|
export MODULE_INIT=()
|
|
|
|
export MODULE_PIDS=""
|
2016-01-12 13:39:54 -06:00
|
|
|
|
|
|
|
register_bar_module() {
|
2016-01-12 15:02:12 -06:00
|
|
|
MODULE_MATCH[$1]=$2
|
|
|
|
MODULE_CALLBACK[$1]=$3
|
|
|
|
MODULE_DATA[$1]=
|
|
|
|
MODULE_CONTENT[$1]=
|
2016-07-27 08:57:56 -05:00
|
|
|
MODULE_INIT[$1]=$4
|
|
|
|
${MODULE_INIT[$1]} &
|
|
|
|
PID=$!
|
2016-07-29 11:20:11 -05:00
|
|
|
echo $PID > "$BAR_PATH/modules/$3.pid"
|
2016-09-02 21:14:45 -05:00
|
|
|
echo -e "Registered Bar Module: $1 $2 $3 $4 with PID $PID" >> "$BAR_LOG"
|
2016-01-12 13:39:54 -06:00
|
|
|
}
|
|
|
|
export -f register_bar_module
|
|
|
|
|
2016-07-29 11:20:11 -05:00
|
|
|
for f in "$BAR_PATH/modules/"*-bm.bash; do
|
2016-09-02 21:14:45 -05:00
|
|
|
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
|
2016-01-12 15:02:12 -06:00
|
|
|
done
|
2016-01-12 13:39:54 -06:00
|
|
|
|
2016-01-11 09:22:54 -06:00
|
|
|
while read -r line; do
|
2016-01-12 15:41:12 -06:00
|
|
|
# echo -e "Bar Line: $line" >> "$BAR_LOG"
|
2016-01-12 15:02:12 -06:00
|
|
|
for i in ${!MODULE_MATCH[@]}; do
|
2016-09-02 21:14:45 -05:00
|
|
|
echo ${!MODULE_MATCH[@]} >> $BAR_LOG
|
2016-01-12 15:02:12 -06:00
|
|
|
if [[ $line == ${MODULE_MATCH[$i]} ]]; then
|
2016-09-02 21:14:45 -05:00
|
|
|
echo -e "Bar Module Update: [$i] Matched ${MODULE_MATCH[$i]} with $line" >> "$BAR_LOG"
|
2016-01-12 15:41:12 -06:00
|
|
|
MODULE_CONTENT[$i]="$("${MODULE_CALLBACK[$i]}" "$line")"
|
|
|
|
# echo -e "New Module Content: "${MODULE_CONTENT[$i]} >> "$BAR_LOG"
|
2016-01-12 15:02:12 -06:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2016-01-12 15:34:04 -06:00
|
|
|
l_content=""
|
|
|
|
c_content=""
|
|
|
|
r_content=""
|
2016-01-12 15:02:12 -06:00
|
|
|
for i in ${!MODULE_CONTENT[@]}; do
|
2016-01-12 15:34:04 -06:00
|
|
|
if [ $i -ge 30000 ]; then
|
2016-01-12 15:41:12 -06:00
|
|
|
r_content="$r_content ${MODULE_CONTENT[$i]}"
|
2016-01-12 15:34:04 -06:00
|
|
|
elif [ $i -ge 20000 ]; then
|
2016-09-02 21:14:45 -05:00
|
|
|
c_content="$c_content${MODULE_CONTENT[$i]} "
|
2016-01-12 15:34:04 -06:00
|
|
|
else
|
2016-09-02 21:14:45 -05:00
|
|
|
l_content="$l_content${MODULE_CONTENT[$i]} "
|
2016-01-12 15:34:04 -06:00
|
|
|
fi
|
2016-01-12 13:39:54 -06:00
|
|
|
done
|
|
|
|
|
2016-09-02 21:14:45 -05:00
|
|
|
printf "%s\n" "%{l} $l_content %{c}$c_content %{r}$r_content "
|
2016-01-11 09:22:54 -06:00
|
|
|
done
|
|
|
|
|
2016-01-12 15:41:12 -06:00
|
|
|
# echo -e "\nEND BAR LOG" >> "$BAR_LOG"
|
2016-01-12 15:02:12 -06:00
|
|
|
|