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/battery-bm.bash

28 lines
668 B
Bash
Raw Normal View History

#!/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