Skip to content

Keepawake Between WSL and Windows

Ilia edited this page Nov 9, 2026 · 1 revision

The counting happens in WSL, the executing in Windows. The state file lies on the Windows drive (C:\Users\<user>\.keepawake\state.json) because PowerShell reads it — and reads it at the moment WSL may already have stopped. The other direction, reading from Windows over \\wsl$, breaks exactly when it is needed.

Time in the file is whole Unix-epoch UTC seconds only. date +%s, time.time() and [DateTimeOffset]::UtcNow.ToUnixTimeSeconds() give the same integer, and the comparison does not depend on the switch to summer time — otherwise on the last Sunday of October, when the local hour repeats twice, the system would be an hour out.

Fail-safe everywhere. The Windows side keeps the system awake only if the file was read, the schema's version is its own, the deadline is in the future and updated_ts is younger than fifteen minutes. The last is the protection against "WSL died and the file remained": the detector runs once a minute and refreshes the stamp even when nothing has changed. Any failure means "release": failing to sleep is a battery flattened overnight, sleeping too early is pressing a button.

A button carries the deadline it was sent for (extend:1757000000). Without that, a press on yesterday's notification would extend the hold at an arbitrary moment the next day; the window is now checked, and a stale button answers with an alert.


Generated from docs/keepawake.md; edit it there, then rebuild with wiki/build.py.

Clone this wiki locally