The logic to check for voltages in "battery maintain" is slightly broken, resulting in the feature not working.
❯ battery maintain 11.4V
06/28/24-17:39:03 - Called with 11.4 maintain
06/28/24-17:39:03 - Error: 11.4 is not a valid setting for battery maintain. Please use a number between 0 and 100, or an action keyword like 'stop' or 'recover'.
--- a/battery.sh
+++ b/battery.sh
@@ -672,10 +672,9 @@ if [[ "$action" == "maintain" ]]; then
fi
is_voltage=true
- fi
# Check if setting is value between 0 and 100
- if ! valid_percentage "$setting"; then
+ elif ! valid_percentage "$setting"; then
log "Called with $setting $action"
# If non 0-100 setting is not a special keyword, exit with an error.
if ! { [[ "$setting" == "stop" ]] || [[ "$setting" == "recover" ]]; }; then
The logic to check for voltages in "battery maintain" is slightly broken, resulting in the feature not working.
Parts of https://github.com/actuallymentor/battery/pull/224 got rewritten in a subsequent merge, introducing the problem.
This is a quick fix: