nosleepp keeps your computer awake while AI agents are actively working.
It is built for agent tools such as Codex, Claude Code, OpenCode, Antigravity, and Cursor. It does not treat an app as working just because it is open. Instead, it samples process activity and reports agents that show measurable CPU or child-process activity.
| Platform | Status | Sleep prevention |
|---|---|---|
| Windows x64 | Supported | Native SetThreadExecutionState |
| macOS Apple Silicon | Supported(still testing) | Built-in caffeinate -i |
| macOS Intel | Supported(still testing) | Built-in caffeinate -i |
| Linux x64 | Supported | systemd-inhibit |
| Linux arm64 | Supported | systemd-inhibit |
nosleepp prevents system idle sleep. It does not force the display to stay awake.
go install github.com/peterintech/nosleepp@latest
nosleepp watchnpm install -g nosleepp
nosleepp watchBuild and run directly from this repository:
go build -o nosleepp.exe .
.\nosleepp.exe watchOn macOS:
go build -o nosleepp .
./nosleepp watchCheck whether any agent is actively working:
nosleepp listKeep the computer awake while agents are working:
nosleepp watchShow open agents too, even if they are idle:
nosleepp list --allCheck once, then exit with a status code:
nosleepp watch --oncenosleepp takes two process snapshots separated by a sample window. The default sample window is 5s.
An agent is marked working when either:
- the agent process or one of its descendant processes gains enough CPU time during the sample window (
250mson Windows/macOS,10mson Linux), or - a descendant process appears or disappears during the sample window.
An agent is marked idle when the process is open but no meaningful activity is detected.
By default, list only shows working agents. Use --all to include idle agents.
nosleepp detects these agent process names by default:
| Agent | Process names |
|---|---|
| Codex | codex, Codex |
| Claude Code | claude |
| OpenCode | opencode |
| Antigravity | antigravity |
| Cursor | Cursor, cursor |
Matching is case-insensitive, and .exe is ignored.
Lists agents that are actively working.
nosleepp list
nosleepp list --all
nosleepp list --json
nosleepp list --sample 5s --cpu-threshold 100msDefault behavior:
- samples activity for
5s - prints only
workingagents - prints
No working agents found.if matching agent apps are open but idle - does not change power state
Text output columns:
| Column | Meaning |
|---|---|
AGENT |
Human-readable agent name |
PID |
Process ID |
PROCESS |
Executable name |
STATUS |
working or idle |
CPU_DELTA |
CPU time gained during the sample |
CHILDREN |
Number of descendant processes |
EVIDENCE |
Why it was marked working, such as cpu or children |
Watches for working agents and prevents system idle sleep while work is active.
nosleepp watch
nosleepp watch --interval 5s --quiet 3m
nosleepp watch --onceDefault behavior:
- samples activity for
5s - polls every
10s - prevents system idle sleep when working agents are found
- keeps the computer awake for
3mafter activity stops - releases the no-sleep lock and exits after the quiet window
- restores normal sleep behavior on
Ctrl+C
--once checks once and exits. Useful for scripts. Exits 0 when at least one working agent is found, 1 when none are found.
Holds the no-sleep lock directly, independent of agent detection. Use it to verify that OS sleep prevention works on your platform.
nosleepp power-test --duration 2mpower-test acquires the no-sleep lock, prints a message, and holds the lock until the duration elapses or Ctrl+C is pressed. Exits 0 on success, 2 if --duration is not greater than zero, 3 if the lock could not be acquired.
Prints version/build information.
| Flag | Description |
|---|---|
--agent |
Add or override an agent signature. Format: name=process1,process2. Can be passed more than once. |
--config |
Reserved for future config-file support. Accepted but not implemented yet. |
| Flag | Default | Description |
|---|---|---|
--all |
off | Show idle/open matching agents as well as working agents |
--json |
off | Print machine-readable JSON |
--sample |
5s |
How long to wait between snapshots. Longer reduces false negatives. |
--cpu-threshold |
250ms |
CPU activity required to mark an agent as working. Lower is more sensitive. Defaults to 10ms on Linux. |
| Flag | Default | Description |
|---|---|---|
--interval |
10s |
How often to check for activity |
--sample |
5s |
Activity sample window used on each poll |
--cpu-threshold |
250ms |
CPU activity required during the sample window (defaults to 10ms on Linux) |
--quiet |
3m |
How long to stay awake after the last detected activity |
--once |
off | Check once and exit (0 if working agent found, 1 if not) |
--json |
off | Print match details as JSON when state changes |
| Code | Meaning |
|---|---|
0 |
Success, or watch --once found a working agent |
1 |
watch --once found no working agents |
2 |
Invalid CLI usage or agent flag |
3 |
Failed to acquire/release platform power state or watcher runtime error |
nosleepp watchLeave this running in a terminal. When Codex is actively working, system idle sleep is blocked. When work stops and the quiet window expires, nosleepp releases the lock and exits.
nosleepp listIf it prints No working agents found., your agent apps may still be open, but they are not currently doing observable work.
nosleepp list --allThis shows matching agents even when idle. If your agent does not appear here, add a custom process signature with --agent.
nosleepp watch --cpu-threshold 100ms --sample 8sThis catches lighter activity, at the cost of more possible false positives.
nosleepp watch --cpu-threshold 1sThis reduces idle false positives, but may miss lightweight agent tasks.
nosleepp power-test --duration 2mUse this when you want to verify the platform power lock without depending on agent detection. If power-test cannot keep the machine awake, the issue is in OS-level sleep prevention rather than process matching.
If you run the Linux binary inside WSL on a Windows PC, systemd-inhibit only applies inside the WSL/Linux environment. It should not be treated as proof that Windows host sleep is blocked. For Windows host sleep prevention, run the Windows nosleepp binary from PowerShell or Command Prompt.
- Linux sleep prevention requires
systemd-inhibit, which is available on many systemd-based desktop distributions.nosleeppuses--what=idle:sleepso it blocks idle sleep and system sleep requests while the lock is held. Manual suspend behavior can still depend on the desktop environment and system policy. - Activity detection is based on CPU and descendant-process changes.
- If an agent is waiting on a network response without CPU or child-process activity, it may look idle after the quiet window.
--configis reserved for future use and is not implemented yet.nosleeppprevents system idle sleep, not display sleep.
Contributions are welcome. Please open an issue first to discuss what you would like to change.
git clone https://github.com/peterintech/nosleepp.git
cd nosleepp
go build .go test ./...Build the local platform binary:
go build .Cross-compile macOS and Linux from Windows:
$env:GOOS="darwin"; $env:GOARCH="arm64"; go build ./...
$env:GOOS="darwin"; $env:GOARCH="amd64"; go build ./...
$env:GOOS="linux"; $env:GOARCH="amd64"; go build ./...
$env:GOOS="linux"; $env:GOARCH="arm64"; go build ./...
Remove-Item Env:\GOOS, Env:\GOARCHcmd/— CLI command definitionsinternal/— core detection and platform logicnpm/— npm package wrapper (launcher scripts and platform binaries)