Go to file
Krzysztof kuhy Rudnicki d2f75f7f21
Some checks are pending
pre-commit / pre-commit (push) Waiting to run
Tests / test (3.10) (push) Waiting to run
Tests / test (3.11) (push) Waiting to run
Tests / test (3.12) (push) Waiting to run
Replace sleep-and-hope audio waits with per-cycle presence checks
Two spots blocked the alarm on a timer, guessing when the monitor's HDMI
sink would be "ready":

- _activate_all_outputs polled _list_real_sinks in a loop with
  time.sleep, waiting up to 20s for ALARM_AUDIO_SINK to appear.
- main() slept DISPLAY_WAKE_WAIT_SECONDS (5s) after waking the display
  before audio setup.

Both are gone. Activation now forces every card's output profile on and
activates whatever sink is present at that instant; the beep loop's
_play_on_all_sinks already re-lists real sinks every cycle, so a slow
monitor is swept in the moment it actually enumerates — a real presence
check, never a timed guess. main() wakes the display and proceeds
immediately; the monitor powers on in parallel.

Removes now-dead constants ALARM_AUDIO_CARD, ALARM_AUDIO_PROFILE,
ALARM_AUDIO_SINK_WAIT_SECONDS, ALARM_AUDIO_SINK_POLL_SECONDS,
DISPLAY_WAKE_WAIT_SECONDS. Activation returns in ~0.26s (was up to 20s);
the test suite drops from ~12s to ~2s (two main() tests were each really
sleeping 5s). 100% branch coverage retained.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018SJ6HYXhBmYs3SiGBZv1rF
2026-07-11 18:51:03 +02:00
.github/workflows Extract wake_alarm from testsAndMisc as a standalone repo 2026-06-22 12:31:40 +02:00
phone_app Add wake_alarm_sync phone-side Flutter companion app 2026-07-10 23:16:11 +02:00
scripts Add CI-mirror pre-push gate + requirements-sync check 2026-07-11 17:51:16 +02:00
wake_alarm Replace sleep-and-hope audio waits with per-cycle presence checks 2026-07-11 18:51:03 +02:00
.gitignore Add CI-mirror pre-push gate + requirements-sync check 2026-07-11 17:51:16 +02:00
.pre-commit-config.yaml Add CI-mirror pre-push gate + requirements-sync check 2026-07-11 17:51:16 +02:00
CLAUDE.md Document the durable-clone editable-install requirement 2026-06-22 12:54:27 +02:00
install.sh Extract wake_alarm from testsAndMisc as a standalone repo 2026-06-22 12:31:40 +02:00
pyproject.toml Point gatelock at the consolidated utils monorepo 2026-07-10 14:01:43 +02:00
README.md Extract wake_alarm from testsAndMisc as a standalone repo 2026-06-22 12:31:40 +02:00
requirements.txt Point gatelock at the consolidated utils monorepo 2026-07-10 14:01:43 +02:00
shutdown-wrapper.sh Fire alarm daily, harden dismissal challenge; ignore wake_state.json 2026-07-10 23:14:40 +02:00
sleep-hook.sh Extract wake_alarm from testsAndMisc as a standalone repo 2026-06-22 12:31:40 +02:00
wake-alarm-fans.sh Extract wake_alarm from testsAndMisc as a standalone repo 2026-06-22 12:31:40 +02:00
wake-alarm.service Extract wake_alarm from testsAndMisc as a standalone repo 2026-06-22 12:31:40 +02:00

wake_alarm

A hibernate-scheduled weekend wake alarm: the machine hibernates overnight on alarm days and wakes itself via rtcwake, then shows a fullscreen, challenge-dismissed alarm with fan ramp and optional TP-Link Tapo P110 smart-plug control.

Install

bash install.sh

This installs the package + dependencies into system Python's user site-packages (the systemd service runs /usr/bin/python directly, not a venv — see CLAUDE.md), installs the systemd user service, the systemd-sleep resume hook, the shutdown wrapper that triggers hibernate on alarm nights, the fan-ramp script, and (optionally) python-kasa for smart-plug control.

Usage

python -m wake_alarm._alarm --demo   # test the alarm window (safe, closeable)

The alarm fires automatically via the hibernate/wake cycle once installed; no manual invocation is needed in normal operation.

Development

python -m venv .venv && .venv/bin/pip install -r requirements.txt
.venv/bin/pre-commit install && .venv/bin/pre-commit install --hook-type pre-push
.venv/bin/python -m pytest wake_alarm/tests/ --cov=wake_alarm --cov-branch --cov-fail-under=100

See CLAUDE.md for scheduling details, the hibernate/rtcwake mechanism, the cross-repo workout_log.json read, and production deployment gotchas.