← Back to list

Introducing awake: a tiny CLI that keeps your Mac awake with the lid closed

AI-driven development has become part of my daily workflow, and I often want my Mac to keep running without sleeping — for long jobs, or so…

tanabee · 2026-05-25 08:21 · 0 claps · 1.8 min read
#claude-code #codex-cli #gemini-cli #antigravity-cli #awake
Open on Medium ↗
Wiki topics: LLM · Large Language Models AI · AI · General 💪 · Fitness & Wellness 🏃 · Running & Endurance

Introducing awake: a tiny CLI that keeps your Mac awake with the lid closed

AI-driven development has become part of my daily workflow, and I often want my Mac to keep running without sleeping — for long jobs, or so I can open the lid briefly during a commute, hand a task to an AI, and let it keep working after I close the lid. You can already do this by combining pmset and caffeinate, but I got tired of remembering the commands, so I wrote a thin wrapper.

git clone https://github.com/tanabee/awake.git ~/.local/share/awake
ln -s ~/.local/share/awake/bin/awake ~/.local/bin/awake

TL;DR: A single awake command does the equivalent of sudo pmset -a disablesleep 1 + caffeinate -is, and reliably undoes it on Ctrl+C or awake stop. Background, status, and stop subcommands included. The whole thing is about 200 lines of bash.

Why I built it

caffeinate alone does not prevent clamshell (lid-closed) sleep. To stop clamshell sleep you need pmset disablesleep 1, which requires sudo and — crucially — persists until you explicitly set it back to 0.

Typing two commands every time and remembering to clean up got old, so I wrapped it in a script that always runs the cleanup itself.

Usage

Foreground (recommended)

awake

You’ll be prompted for your sudo password. Once the running message appears, you can close the lid. When you’re done, Ctrl+C automatically runs sudo pmset -a disablesleep 0 and restores the original state.

awake: disabling sleep (sudo required)
Password:
awake: running (PID=12345, caffeinate PID=12346)
awake: the Mac will stay awake with the lid closed. Press Ctrl+C to release and exit.
^C
awake: restoring sleep settings (sudo pmset -a disablesleep 0)

Background

For when you don’t want a terminal window tied up. Just remember to stop it.

awake start # run in the background
awake status # check state
awake stop # stop (pmset is restored automatically)

awake status output:

awake: running (background)
 pid: 39189
 started: 2026–05–24 13:24:59 JST
 uptime: 1h 03m 12s
 pmset disablesleep: 1
 log: /Users/yuki.tanabe/.local/state/awake/awake.log

Limitations

  • macOS only. It depends on pmset and caffeinate.
  • sudo required. pmset disablesleep needs root.
  • Heat. Closing the lid traps heat in the chassis. Avoid sustained heavy CPU/GPU loads in clamshell mode.

Give it a try

If you want to do AI-driven development on the move, or let a local AI keep working without your Mac going to sleep, give it a try.

It’s brand new, so if you hit bugs please file them on GitHub Issues.

References


메타데이터
post_id
16d58ab9e99e
slug
introducing-awake-a-tiny-cli-that-keeps-your-mac-awake-with-the-lid-closed-16d58ab9e99e
url
https://medium.com/@tanabee/introducing-awake-a-tiny-cli-that-keeps-your-mac-awake-with-the-lid-closed-16d58ab9e99e
canonical_url
https://medium.com/@tanabee/introducing-awake-a-tiny-cli-that-keeps-your-mac-awake-with-the-lid-closed-16d58ab9e99e
author_url
https://medium.com/@tanabee
status
ok
fetched_at
2026-06-09 15:37:30