dotfiles/.local/bin/batmon

17 lines
413 B
Plaintext
Raw Normal View History

2024-07-03 19:59:32 -04:00
#!/bin/sh
FULL_THRESHOLD=80
FULL_COLOR="#31f53e"
read -r capacity </sys/class/power_supply/BAT1/capacity
read -r status </sys/class/power_supply/BAT1/status
if [ "$capacity" -ge "$FULL_THRESHOLD" ] && [ "$status" = "Not charging" ]; then
status="Full"
fi
if [ "$status" = "Full" ]; then
printf '<fc=%s>%s%%</fc> (%s)\n' "$FULL_COLOR" "$capacity" "$status"
else
printf '%s%% (%s)\n' "$capacity" "$status"
fi