This repository has been archived on 2024-03-28. You can view files and clone it, but cannot push or open issues or pull requests.
dotfiles/env/wm/extras/bar/modules/example.bash

41 lines
1.4 KiB
Bash
Raw Normal View History

2016-01-12 15:02:12 -06:00
#!/usr/bin/env bash
source "$DOTFILES_PATH/variables.bash"
# This defines this module's priority, determining where it will be rendered on
# the bar relative to other modules.
PRIORITY=2500
# This is the trigger that the incoming line from the FIFO must match in order
# to be processed by this module.
MATCH_PREFIX="BM_EXAMPLE"
MATCH="$MATCH_PREFIX*"
# Define the function that will be called upon the match being triggered. This
# should process the first argument (the line from the FIFO) and echo the
# desired bar output.
bar_module_example() {
2016-12-11 15:17:59 -06:00
# Write the line from the 10th character (cutting off the MATCH_PREFIX)
echo -e "${1:10}"
2016-01-12 15:02:12 -06:00
}
# Export our function so that the formatter script can call it.
2016-12-11 15:17:59 -06:00
export -f bar_module_example
2016-01-12 15:02:12 -06:00
# Create a function that will periodically write to the FIFO with the correct
# prefix, thereby updating the module.
bar_module_example_updater() {
while [ $BAR_RUNNING -eq 1 ]; do
echo -e "$MATCH_PREFIX""$(date +%H.%M)" > "$BAR_FIFO"
sleep 30
done
}
2016-12-11 15:17:59 -06:00
export -f bar_module_example_updater
2016-01-12 15:02:12 -06:00
# 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"Loading... > "$BAR_FIFO"
2016-12-11 15:17:59 -06:00
# 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"