Keep your PC awake when it matters.
Insomnia is a lightweight Windows app that prevents your computer from sleeping — automatically when AI coding agents are working, when specific apps are running, or manually with a toggle. No more losing progress to an untimely screen timeout.
You're running Claude Code, Aider, or another AI coding tool. It's churning through a complex task. You step away for a few minutes — and your PC goes to sleep, killing the process. You come back to a broken session and lost work.
Setting your screen timeout to 2 hours works, but then your PC never sleeps when you actually want it to.
Insomnia solves this. It keeps your PC awake only when something is actively running that needs it, and gets out of the way the rest of the time.
Insomnia has built-in support for AI coding tools with two types of monitoring:
| Integration | Type | How It Works |
|---|---|---|
| Claude Code | Hook-based | Knows when Claude is actively working (not just open). Wakes on tool use, sleeps when idle. |
| Cursor | Process-based | Keeps awake while Cursor is running |
| Aider | Process-based | Keeps awake while aider.exe is running |
| OpenAI Codex CLI | Process-based | Keeps awake while codex.exe is running |
| Ollama | Process-based | Keeps awake during local AI model inference |
The Claude Code integration is hook-based — it hooks directly into Claude Code's event system so your PC stays awake only while Claude is actively running tools and generating code, not when it's sitting idle waiting for your next prompt. Once Claude finishes, Insomnia releases within 90 seconds.
Add any application as a trigger. Insomnia auto-discovers all installed apps on your system:
- Windows Start Menu programs
- Registry-installed apps
- Microsoft Store apps
- Desktop shortcuts
- Or browse manually for any
.exe
When a watched app is running, your PC stays awake. Close it, and Insomnia steps back.
A simple on/off switch for when you just need your PC to stay awake right now. No questions asked.
Insomnia lives in your system tray, out of your way. The tray icon tells you at a glance:
- Purple owl (eyes open) — Staying Awake (keeping your PC on)
- Grey owl (eyes closed) — Inactive (normal sleep behavior)
- Hover tooltip — Shows exactly why it's awake: "Staying awake for — Claude Code", "Staying awake for — Manual mode + Chrome"
Close the window and it keeps running in the tray. Right-click for quick controls.
Head to the Releases page and download the latest .exe installer.
winget install StanleyProjects.Insomnia
scoop bucket add stanley-projects https://github.com/stanley-projects/scoop-stanley
scoop install stanley-projects/insomnia
Requires Node.js (v18+).
git clone https://github.com/stanley-projects/Insomnia.git
cd Insomnia
npm install
npm startInsomnia uses Electron's powerSaveBlocker API to prevent Windows from entering sleep mode. It evaluates whether to stay awake based on three signals:
- Manual toggle — User explicitly wants the PC awake
- Process monitoring — Polls
tasklistevery 10 seconds to check if watched apps are running - Hook-based sessions — For tools like Claude Code, lightweight hooks signal activity to a shared session file (
~/.insomnia/agent-sessions.json). Sessions expire after 90 seconds of inactivity.
If any trigger is active, the PC stays awake. When all triggers go inactive, normal sleep behavior resumes.
When you enable the Claude Code integration, Insomnia adds hooks to ~/.claude/settings.json that fire on:
UserPromptSubmit,PreToolUse,PostToolUse,PermissionRequest,Notification→ signal activity (stay awake)SessionEnd→ signal idle (allow sleep)
This means your PC stays awake precisely while Claude is doing work — reading files, running commands, writing code — and goes back to normal the moment it stops. No wasted power, no interrupted sessions.
Settings are stored in your Electron user data directory and persist across restarts:
- Watched apps — list of executables to monitor, each with an enable/disable toggle
- Watched integrations — AI tools with their monitoring type and enabled state
- Manual awake state — remembered across restarts
| Main Window | Add Trigger — Integrations | Add Trigger — Apps | System Tray |
|---|---|---|---|
![]() |
![]() |
![]() |
![]() |
- AI-assisted coding — Keep your PC awake while Claude Code, Aider, or Codex work on long tasks
- Long downloads — Watch your browser or download manager
- Video rendering — Watch your editing software so your PC doesn't sleep mid-render
- Presentations — Manual toggle before you present, toggle off when done
- Game updates — Watch Steam or your game launcher during large updates
- Compiling — Watch your IDE during long builds
- 3D printing — Watch your slicer or printer software
- Electron — Cross-platform desktop framework (Windows support)
- Plain HTML/CSS/JS — No React, no bundlers, no build tools
- Zero external dependencies — Only Electron itself
- Windows APIs —
tasklistfor process detection, PowerShell for app discovery,powerSaveBlockerfor sleep prevention
Pull requests welcome. If you'd like to add an integration for another AI coding tool or improve app discovery, feel free to open a PR.
MIT



