Skip to content

🐛 first check for recover setting, then valid_percentage#292

Merged
actuallymentor merged 2 commits intoactuallymentor:mainfrom
alexkarpitski:main
Jul 9, 2024
Merged

🐛 first check for recover setting, then valid_percentage#292
actuallymentor merged 2 commits intoactuallymentor:mainfrom
alexkarpitski:main

Conversation

@alexkarpitski
Copy link
Copy Markdown
Contributor

Problem
battery maintain_synchronous recover should launch at login per ~/Library/LaunchAgents/battery.plist. It fails, however, with the message in logs: Error: recover is not a valid setting for battery maintain. Please use a number between 0 and 100. As a result, the policy is not enforced and requires battery maintain 80 to be entered manually.

Solution
Reorder valid_percentage and recover clauses.

Evidence
Before the fix:

alex@alex-mbp ~ % battery maintain_synchronous recover
07/08/24-11:59:21 - Error: recover is not a valid setting for battery maintain. Please use a number between 0 and 100

With the fix:

alex@alex-mbp ~ % battery maintain_synchronous recover
07/08/24-12:03:29 - Debug trail. User: alex, config folder: /Users/alex/.battery, logfile: /Users/alex/.battery/battery.log, file called with 1: maintain_synchronous, 2: recover
07/08/24-12:03:29 - Recovering maintenance percentage 80
07/08/24-12:03:29 - Not triggering discharge as it is not requested
07/08/24-12:03:29 - Charging to and maintaining at 80% from 82%

@alexkarpitski
Copy link
Copy Markdown
Contributor Author

ptal @actuallymentor

@actuallymentor actuallymentor merged commit 89bedc1 into actuallymentor:main Jul 9, 2024
@actuallymentor
Copy link
Copy Markdown
Owner

Thank you very much for your fix on this @alexkarpitski! Merging now.

panoskava pushed a commit to panoskava/battery that referenced this pull request Mar 17, 2026
🐛 first check for recover setting, then valid_percentage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants