feat(rofi): battery charge-limit toggle in the System menu
All checks were successful
Check / eval (push) Successful in 2m54s

Add a `batterylimit` nomarchy-menu subcommand — a preset picker
(80/90/60/Off/Custom…) that writes settings.power.batteryChargeLimit via
theme-sync (--no-switch; lands on the next sys-rebuild, power.nix's oneshot
applies it). Surfaced as a first-class System row, self-gated on the
charge_control_end_threshold sysfs node like Power profile.

Moved out of the gum control-center (removed its Battery Limit case +
choose entry) so the toggle lives in one place — the rofi menu Bernardo
actually uses, per his request.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-07 22:50:26 +01:00
parent a8391c381d
commit 60c6f14c08
5 changed files with 79 additions and 38 deletions

View File

@@ -122,7 +122,7 @@ function appearance_menu() {
function toggles_menu() {
while true; do
choice=$(gum choose "Auto-commit" "Auto-timezone" "Night Light" "Updates" "Battery Limit" "Bluetooth" "Printing" "Terminal" "Keyboard Layout" "Auto-Login" "Back")
choice=$(gum choose "Auto-commit" "Auto-timezone" "Night Light" "Updates" "Bluetooth" "Printing" "Terminal" "Keyboard Layout" "Auto-Login" "Back")
case "$choice" in
"Auto-commit")
cur=$(get_state "settings.autoCommit")
@@ -166,35 +166,6 @@ function toggles_menu() {
fi
sleep 1
;;
"Battery Limit")
# 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")
if [ "$cur" = "true" ]; then