Files
battery/battery.sh
Ira Abramov f42628e609 feat: add percentage range support to maintain command
- Add valid_percentage_range() validation function
  - Validates NUMBER-NUMBER format
  - Ensures lower < upper
  - Enforces lower >= 10 and upper <= 100
  - No maximum range spread limit

- Update maintain_synchronous to handle ranges
  - Parse range into lower_bound and upper_bound
  - Enable charging when battery < lower_bound
  - Disable charging when battery >= upper_bound
  - Fully backward compatible with single values

- Update help message and README
  - Add examples: 'battery maintain 70-80'
  - Document range syntax alongside single values

- Maintain daemon persists ranges across reboots
  - Stores range format (e.g., '70-80') in maintain.percentage
  - Recovery logic auto-detects and restores ranges

Tested:
- Single value (80) works as before
- Valid ranges (70-80) work correctly
- Invalid ranges rejected (80-70, 5-15, 95-105, 70-70)
- Status display shows ranges properly (70% - 80%)

CLI-only feature. GUI support deferred to future work.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-21 13:10:08 +03:00

26 KiB
Executable File