Let the idle timings know whether you are plugged in

An idle screen costs a screen on wall power and the rest of your
afternoon on battery, so they should not be the same number. hypridle
has no concept of a power source -- one config, one set of timeouts --
so rather than maintaining two configs and swapping them, panama-idle
builds the single config from whichever key set applies, and IdleLock
rebuilds it when the charger comes or goes. That runs through the same
400ms debounce a settings change uses, so a loose charger cannot
restart hypridle in a loop.

The battery keys fall back to their AC counterparts rather than to the
schema defaults. Without that, unplugging would silently override a
deliberately long timing with a shipped short one, which is the kind
of thing you would notice only by losing work.

A machine with no battery reads none of it and generates exactly what
it generated before. The contract pins that alongside the two obvious
directions, and was checked by sabotaging the detection to confirm it
fails rather than passing vacuously.
This commit is contained in:
Gabriel Brown
2026-08-21 22:18:29 -04:00
parent 3c359f3f7e
commit bc6d63b70f
8 changed files with 187 additions and 8 deletions
@@ -107,6 +107,18 @@ Singleton {
}
}
// The charger came or went. hypridle cannot express two sets of timeouts,
// so the config is rebuilt from the other set and the daemon restarted --
// the same path a settings change takes, through the same debounce, so a
// flapping charger cannot restart hypridle in a loop.
Connections {
target: Battery
function onAcChanged(online: bool): void {
if (root.managed)
regenerate.restart();
}
}
Timer {
id: regenerate
interval: 400