fix(theme): #79 review fixes — wrap-around schedule + HH:MM guard
All checks were successful
Check / eval (push) Successful in 4m6s

Two low-severity edge bugs from a fresh-eyes review of the session batch:

- cmd_auto: an inverted schedule (sunrise > sunset, i.e. a day window that
  crosses midnight) stayed perpetually on the day theme — the old
  `not between` shortcut is an empty interval when sunrise > sunset.
  Replaced with a real wrap-around: daytime = mins >= sunrise or
  mins < sunset, so both directions switch. Normal sunrise < sunset path
  is unchanged (checks.auto-theme still holds).
- rofi autotheme HH:MM validator: `[0-2][0-9]` accepted 24:00–29:59.
  Tightened the case pattern to `[01][0-9]:[0-5][0-9]|2[0-3]:[0-5][0-9]`
  so out-of-range hours are rejected (they'd otherwise skew the boundary).

(Two other review findings dismissed: papirus DOES ship breeze/breeze-dark
so that iconPacks prefix is correct; the doctor RAM-unknown row is cosmetic
since /proc/meminfo is always readable.)

Verification: py_compile; boundary truth-table (normal + wrap-around);
HH:MM case table (23:00/19:59/20:00 accept, 24/25/30:00 reject); auto
--which normal-case unchanged; menu bash -n; flake check green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Bernardo Magri
2026-07-11 08:19:05 +01:00
parent 808990592d
commit 2fa5231215
3 changed files with 26 additions and 5 deletions

View File

@@ -528,10 +528,13 @@ def cmd_auto(args) -> None:
sunset = _hhmm_to_min(at.get("sunset", "20:00"), "20:00")
now = time.localtime()
mins = now.tm_hour * 60 + now.tm_min
# Normal case sunrise < sunset: daytime is the span between them. If a
# user inverts them, treat the between-span as night (still coherent).
between = sunrise <= mins < sunset
daytime = between if sunrise <= sunset else not between
# Daytime is the span between sunrise and sunset. Also handle a
# wrap-around pair (sunrise after sunset → the day window crosses
# midnight), so an inverted schedule still switches both ways.
if sunrise <= sunset:
daytime = sunrise <= mins < sunset
else:
daytime = mins >= sunrise or mins < sunset
target = day if daytime else night
if args.which: