Log the probe's skipped mornings once a day

A morning with no ring_probe line could mean kuhy was logged in or the
probe never ran. Also: the morning ring meets the greeter-only state,
not a masked lightdm; correct the docs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Krzysztof Rudnicki 2026-11-22 19:13:55 +01:00
parent 0432a9968f
commit be45e5969a
4 changed files with 30 additions and 6 deletions

View File

@ -191,7 +191,11 @@ silence to each monitor with IEC958 muted (restored afterwards) and logs one
`ring_probe` line per monitor. `_ring_probe.maybe_probe` starts
`wake-alarm-ring-probe.service` once, at `A − 5` on the first morning with no
graphical session (the state a fallback ring meets), and writes
`ring_probe_done`. Read it with `journalctl -u wake-alarm-ring-probe`.
`ring_probe_done`. "No graphical session" means greeter only: lightdm is
masked only before 05:00, when no ring can happen. A morning kuhy is already
logged in at `A − 5` logs one `ring_probe: waiting_for_no_session` event a
day instead. Read it with `journalctl -u wake-alarm-ring-probe` and
`grep ring_probe ~/.local/state/wake_alarm/events.jsonl`.
vmbox gate: `ring-alsa-monitor-sinks`, `ring-alsa-monitor-probe`
(`scripts/vmbox/guest_cases_monitors.sh`).

View File

@ -54,10 +54,13 @@ went quiet after 07:43 on 11-01 is a separate phone question.
**Sound.** 100 %, unmuted, a tone that rises over the first 60 s.
- Active graphical session on seat0 → user PipeWire (`wpctl` + `pw-play`).
- Otherwise (night lockdown: lightdm masked, nobody logged in; kuhy is not in
`audio`) → root system unit `wake-alarm-ring-alsa.service` playing straight
- Otherwise (kuhy is not in `audio`) → root system unit `wake-alarm-ring-alsa.service` playing straight
to the speakers' card (`ALC897 Analog`, card name `Generic_1`) via `aplay`.
- Both paths also ring every connected monitor (2026-11-22, `DOCS-bypass.md`).
- A morning ring meets the "otherwise" state: the night lockdown masks
lightdm 23:00-05:00 only, and from 05:00 seat0 holds lightdm's greeter
(an X server, but no kuhy session) until kuhy logs in. 2026-11-22: greeter
at 05:00, ALSA ring 07:51, kuhy's session 10:09.
### PC wakes itself (nights before Tue/Wed/Thu)

View File

@ -16,7 +16,7 @@ from datetime import timedelta
from typing import TYPE_CHECKING
from wake_alarm._constants import LOG_STATE_DIR
from wake_alarm._events import emit
from wake_alarm._events import emit, emit_on_change
from wake_alarm._ring_player import _ok, graphical_session
if TYPE_CHECKING:
@ -33,8 +33,12 @@ def maybe_probe(now: datetime, alarm_at: datetime) -> str | None:
return None
graphical, why = graphical_session()
if graphical:
# Not the state a fallback ring meets; try again tomorrow.
return "waiting_for_no_session"
# Not the state a fallback ring meets; try again tomorrow. Logged
# once a day, so a morning with no ring_probe line is a bug.
reason = "waiting_for_no_session"
key = f"{now.date().isoformat()}|{reason}"
emit_on_change("ring_probe", key, reason, session=why)
return reason
started, out = _ok(["sudo", "-n", "systemctl", "start", PROBE_UNIT])
emit("ring_probe", "started" if started else "failed", session=why, output=out)
if not started:

View File

@ -67,3 +67,16 @@ def test_it_waits_for_a_morning_with_no_session(done_file: Path) -> None:
def test_a_refused_start_is_retried_next_morning(done_file: Path) -> None:
assert _run(-3, graphical=False, started=False) == "failed"
assert not done_file.exists()
def test_a_skipped_morning_is_logged_once_a_day() -> None:
# Without it, a missing ring_probe line at 08:00 cannot tell "kuhy was
# logged in" from "the probe never ran".
with patch.object(_ring_probe, "emit_on_change") as emit:
assert _run(-3, graphical=True) == "waiting_for_no_session"
emit.assert_called_once_with(
"ring_probe",
"2026-11-23|waiting_for_no_session",
"waiting_for_no_session",
session="why",
)