feat(control-center): battery charge-limit as a preset toggle
All checks were successful
Check / eval (push) Successful in 3m10s

The "Battery Limit" entry was a raw number prompt; make it a proper
toggle picker — Off / 80% (recommended) / 90% / 60% / Custom… — writing
settings.power.batteryChargeLimit. Kept in the control-center, where the
baked rebuild-valued System Toggles live (the rofi nomarchy-menu is the
instant surface; the CC holds config values), and reachable from the menu
via System › Control Center. Base machinery (the sysfs oneshot + AC-replug
udev in power.nix) is unchanged, so it lands on the next sys-rebuild like
its siblings.

Instant-effect (no rebuild) is refiled in BACKLOG § PROPOSED as
[blocked:hw]: it needs a udev-writable threshold node, confirmable only on
a laptop with the control.

Verified: V0 (bash -n; nix flake check --no-build, green) + V1
(nomarchy-control-center package builds — the writeShellApplication
shellcheck gate passes). Session spot-check queued in HARDWARE-QUEUE.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-07 19:06:15 +01:00
parent ce89fddab6
commit d078ba2a82
4 changed files with 69 additions and 22 deletions

View File

@@ -167,12 +167,33 @@ function toggles_menu() {
sleep 1
;;
"Battery Limit")
limit=$(gum input --prompt "Enter battery charge limit % (or empty for default): " --placeholder "$(get_state settings.power.batteryChargeLimit)")
if [ -n "$limit" ]; then
set_state "settings.power.batteryChargeLimit" "$limit"
else
set_state "settings.power.batteryChargeLimit" "null"
fi
# Conservation-mode toggle: cap charging to spare the battery,
# or Off to charge full. A preset picker (not a raw number) with
# a Custom escape hatch. This is a baked NixOS system option
# (settings.power.batteryChargeLimit → the sysfs oneshot in
# power.nix), so it lands on the next sys-rebuild like the other
# System Toggles.
cur=$(get_state settings.power.batteryChargeLimit)
sel=$(gum choose --header "Battery charge limit (now: ${cur:-default})" \
"80% (recommended)" "90%" "60%" "Off (charge to 100%)" "Custom…" "Cancel")
case "$sel" in
"80%"*) set_state "settings.power.batteryChargeLimit" "80"
echo "Charge limit set to 80% (requires rebuild)." ;;
"90%") set_state "settings.power.batteryChargeLimit" "90"
echo "Charge limit set to 90% (requires rebuild)." ;;
"60%") set_state "settings.power.batteryChargeLimit" "60"
echo "Charge limit set to 60% (requires rebuild)." ;;
"Off"*) set_state "settings.power.batteryChargeLimit" "null"
echo "Charge limit off — charges to 100% (requires rebuild)." ;;
"Custom…")
limit=$(gum input --prompt "Charge limit % (50100): " --placeholder "$cur")
if [ -n "$limit" ]; then
set_state "settings.power.batteryChargeLimit" "$limit"
echo "Charge limit set to $limit% (requires rebuild)."
fi ;;
*) : ;;
esac
sleep 1
;;
"Bluetooth")
cur=$(get_state "settings.bluetooth.enable")