Keeps the computer awake from Vicinae. Written against @vicinae/api
directly because the Raycast `coffee` extension cannot work here:
- Its `index` command is `menu-bar` mode, which Vicinae does not support.
- Its `status` command crashes on `Cannot read properties of null
(reading 'IsManuallyDecafed')` because it gates on
`LocalStorage.getItem(key) === undefined`. Vicinae resolves a missing
key to `null`, not `undefined` (verified with a runtime probe).
Sleep prevention is an OS-level assertion, so the extension delegates and
gets out of the way:
- macOS: caffeinate -i [-d] [-s] [-t <seconds>]
- Linux: systemd-inhibit --what=idle:sleep --why=<reason> sleep <n|infinity>
The process is spawned detached + unref'd, because Vicinae unloads a
no-view command as soon as its function returns. Timed sessions need no
babysitter: `caffeinate -t` and `sleep <n>` self-terminate.
Commands: toggle (no-view), status (view), caffeinate-for (view).
Two deliberate safety choices:
- Stopping signals the recorded PID rather than running `killall
caffeinate`, so a caffeinate the user started themselves survives.
Verified against a real concurrent `caffeinate -u -dmi` process.
- The PID's name is re-checked with `ps -o comm=` before signalling, since
PIDs get recycled and a stale entry could otherwise kill something
unrelated.
Also: display-sleep prevention is macOS-only, and the UI says so on Linux
rather than pretending systemd-inhibit can hold the display awake.
Verified: vici lint, tsc --noEmit, eslint, 23/23 vitest, vici build, and
live in Vicinae — toggle starts `caffeinate -i` which survives the
command unloading, toggle again stops only ours, both view commands load
with clean stdout/stderr.