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

@@ -34,13 +34,11 @@ Hyprland bind's modmask/keysym against the *actual* layout, whether rofi
2.0.0 changed anything, and that the cheatsheet path still resolves.
### 36. Battery / power quick menu
(Raised by Bernardo, 2026-07-07 — items "battery toggle in a rofi
submenu" + item 6.) Two slices:
- (a) **Move the charge-threshold toggle into the rofi System submenu.**
Iteration #55 put it in the gum control-center; Bernardo wants it as a
first-class row in `nomarchy-menu` System (self-gated on the
`charge_control_end_threshold` sysfs node), reusing the preset picker.
### 36. Battery / power quick menu `[human]`
(Raised by Bernardo, 2026-07-07 — item 6.) Slice (a) — the charge-threshold
toggle in the rofi System submenu — shipped 2026-07-07 (iteration #64;
`nomarchy-menu batterylimit`, self-gated on the sysfs node, and MOVED out
of the gum control-center). Remaining:
- (b) `[human]` **Battery-icon click → a dedicated power menu** offering
charge threshold + power profile (and switching backend to TLP when
relevant). Bernardo will provide a mockup ("when it's time") — hold

View File

@@ -236,6 +236,13 @@ QA machine), the **T14s** (webcam case).
unchanged (the bar still reserves its space). Accepted trade-off
of `layer: bottom`: a floating window dragged over the top strip
can now overlap the bar — confirm that's the only regression.
- [ ] **Battery limit in rofi System** (iteration #64, item 36a) — after
`home-update`: menu System shows a "Battery limit" row (this laptop
exposes the threshold node); picking a preset (80/90/60/Off/Custom)
writes it (`nomarchy-theme-sync get settings.power.batteryChargeLimit`
reflects the pick) and after a `sys-rebuild` the sysfs
`charge_control_end_threshold` matches. The gum control-center no
longer lists Battery Limit (moved, not duplicated).
- [ ] **Config dialogs float** (iteration #63, item 41 cut) — after
`home-update` + relogin: open Bluetooth (blueman-manager) and, if
printing is on, System ▸ Printers (system-config-printer) — each

View File

@@ -17,6 +17,23 @@ Template:
---
## 2026-07-07 — Battery-limit toggle in rofi System (iteration #64, item 36a)
- **Task:** BACKLOG item 36(a) — Bernardo wanted the charge-threshold
toggle as a first-class row in `nomarchy-menu System`, not buried in
the gum control-center where #55 put it.
- **Fix:** `rofi.nix` — new `batterylimit` subcommand: a preset picker
(80%/90%/60%/Off/Custom…) with battery-0XX icons, writing the baked
`settings.power.batteryChargeLimit` via theme-sync `--no-switch` (lands
on next sys-rebuild; power.nix's oneshot applies it). Added a System row
self-gated on the `charge_control_end_threshold` sysfs node (like Power
profile), dispatch, and usage string. **Moved** — removed the duplicate
"Battery Limit" case + choose entry from `nomarchy-control-center.sh` so
it lives in one place.
- **Verified:** V0 green. V1: control-center builds clean (shellcheck),
home activation builds clean (writeShellScriptBin's `bash -n` on the
menu passed); grepped the built script to confirm the row/dispatch/case/
guard are all present. Live menu interaction is a V3 check (queued).
## 2026-07-07 — Floating-window audit, conservative cut (iteration #63, item 41)
- **Task:** BACKLOG item 41 — Bernardo: "take a conservative approach."
Broaden the windowrule float set beyond the mixer.

View File

@@ -692,6 +692,10 @@ ${themeRows}
if [ -e "''${bats[0]}" ] && command -v powerprofilesctl >/dev/null 2>&1; then
row "Power profile" preferences-system-power
fi
# Self-gated on the charge-threshold sysfs node (laptops that
# expose it), like Power profile above.
[ -e "''${bats[0]}/charge_control_end_threshold" ] \
&& row "Battery limit" battery-080
back
} | rofi -dmenu -show-icons -markup-rows -p System) || exit 0
case "$choice" in
@@ -710,6 +714,50 @@ ${themeRows}
*Doctor*) exec "$0" doctor ;;
*"Control Center"*) exec "$0" controlcenter ;;
*"Power profile"*) exec "$0" power-profile ;;
*"Battery limit"*) exec "$0" batterylimit ;;
esac ;;
batterylimit)
# Battery charge-limit preset picker the rofi-System counterpart of
# the control-center's toggle (Bernardo: he wanted this in the menu,
# not buried in the gum TUI). Writes the baked NixOS option
# settings.power.batteryChargeLimit via theme-sync (--no-switch), so
# it lands on the next sys-rebuild the sysfs oneshot in power.nix
# owns applying it (boot + AC-replug). Self-gated in System; guard
# here too in case it's invoked directly.
bats=(/sys/class/power_supply/BAT*)
[ -e "''${bats[0]}/charge_control_end_threshold" ] \
|| { notify-send "Battery limit" "No charge-threshold control on this machine."; exit 0; }
cur=$(nomarchy-theme-sync get settings.power.batteryChargeLimit 2>/dev/null)
sel=$( {
row "80% (recommended)" battery-080
row "90%" battery-090
row "60%" battery-060
row "Off charge to 100%" battery-100
row "Custom" battery
back
} | rofi -dmenu -show-icons -p "Battery limit (now: ''${cur:-default})") || exit 0
set_limit() {
nomarchy-theme-sync --quiet set settings.power.batteryChargeLimit "$1" --no-switch
notify-send "Battery limit" "$2 applies on the next rebuild."
}
case "$sel" in
"$BACK") exec "$0" system ;;
"80%"*) set_limit 80 "Set to 80%" ;;
"90%"*) set_limit 90 "Set to 90%" ;;
"60%"*) set_limit 60 "Set to 60%" ;;
"Off"*) set_limit null "Off charges to 100%" ;;
"Custom"*)
limit=$(rofi -dmenu -p "Charge limit % (50100)" < /dev/null) || exit 0
[ -n "$limit" ] || exit 0
case "$limit" in
*[!0-9]*) notify-send "Battery limit" "Not a whole number: $limit"; exit 0 ;;
esac
if [ "$limit" -ge 50 ] && [ "$limit" -le 100 ]; then
set_limit "$limit" "Set to $limit%"
else
notify-send "Battery limit" "Out of range (50100): $limit"
fi ;;
esac ;;
"")
@@ -734,7 +782,7 @@ ${themeRows}
esac ;;
*)
echo "usage: nomarchy-menu [lookfeel|tools|system|power|power-profile|theme|clipboard|calc|files|emoji|web|network|bluetooth|audio|display|display-profile|printers|capture|colorpicker|keybinds|ask|dnd|nightlight|autotimezone|autocommit|vpn|snapshot]" >&2
echo "usage: nomarchy-menu [lookfeel|tools|system|power|power-profile|batterylimit|theme|clipboard|calc|files|emoji|web|network|bluetooth|audio|display|display-profile|printers|capture|colorpicker|keybinds|ask|dnd|nightlight|autotimezone|autocommit|vpn|snapshot]" >&2
exit 64 ;;
esac
'';

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