Batsignal can be used in shell-scripts to wait for certain battery conditions, or to check current battery conditions. See examples below.
batsignal --wait --state charging && echo "Charger connected!"
batsignal --wait --lt 10 && echo "Battery below 10%!"
batsignal --lt 25 && echo "Battery below 25%!" || echo "Battery okay"
A simple cargo install batsignal
should do it.