How to Keep Your Mac Awake With the Lid Closed for AI Agents (2026)
Whether you are running an autonomous coding loop in the terminal (like Claude Code or Aider), executing database seeding scripts, or serving local LLMs (using Ollama or LM Studio), your background tasks take time. However, the moment you close your MacBook lid to move to a meeting room, catch a flight, or pack up at a coffee shop, macOS automatically triggers system sleep.
This suspends your CPU/GPU cores, immediately kills active terminal processes, drops your server handshakes, and corrupts your model context. How do you bypass this default sleep behavior? Let's analyze every solution to keep your Mac awake with the lid closed.
The Problem: Clamshell Sleep Triggers
Apple enforces system sleep when a notebook lid is closed to preserve battery life and prevent the display from taking on residual heat generated by the keyboard deck under heavy loads. For AI engineers, this default trigger is a productivity killer. Here are five ways to override it.
5 Solutions to Keep Your Mac Running Lid-Closed
1. The Terminal Route (`pmset`)
You can use the built-in Power Management command-line utility to completely disable system sleep triggers.
- Built directly into macOS
- Free to use
- No software downloads required
- Requires `sudo` root privileges
- No safety guards (risk of thermal damage)
- Must be manually toggled off
How to execute: Open Terminal and run `sudo pmset -a disablesleep 1` to disable sleep. *Warning: Remember to run `sudo pmset -a disablesleep 0` to enable normal sleep behaviors when done, or your laptop will stay awake forever, potentially draining your battery completely.*
2. Amphetamine + Enhancer
The most popular general-purpose keep-awake utility on macOS.
- Free and highly customisable
- Dozens of trigger options
- Requires separate "Enhancer" app download
- No hardware thermal safety controls
- Strictly Mac-only utility
3. LidOrbit (Recommended Choice)
A modern anti-sleep application built specifically for hardware-taxing developer workflows and agent loops.
- One-tap native lid-closed overrides
- Active thermal safety monitoring
- Battery check safety alarms below 15%
- Works on both Mac and Windows
- Paid ($5.99 lifetime unlock)
LidOrbit is our recommended option if you want a **safe, set-and-forget experience**. If your AI loops push system thermals too high while closed in your backpack, LidOrbit detects the spike and auto-releases the block, protecting your silicon.
4. USB-C Dummy Display Hack
A physical plug that fools macOS into thinking a monitor is attached.
- Completely fools OS display checks
- Requires buying physical hardware
- Must be plugged in continually
- No thermal threshold safety checks
5. System Settings Clamshell Mode
Apple's native clamshell mode configuration.
- 100% native and supported by Apple
- Requires external display
- Requires external keyboard/mouse
- Must be connected to power adapter
⚠️ Danger Zone: Permanent Terminal Overrides (pmset)
Some guides recommend permanently disabling macOS sleep using commands like sudo pmset -a disablesleep 1. While this stops sleep, it writes the configuration directly to NVRAM (Non-Volatile RAM). This introduces several critical risks:
- Battery Health Deterioration: If you forget to revert this setting, your MacBook will continuously run background processes in your bag, draining your battery cells to 0% and accelerating battery capacity degradation.
- Hardware Thermal Cooking: There is no thermal loop monitoring in raw pmset blocks. If a heavy process starts running while the screen is shut, your Mac will overheat without throttling, causing display panel or internal hardware damage.
For safe, session-based control, stick to user-space API assertions (like those used by LidOrbit or caffeinate) that auto-terminate when the app closes or battery hits 10%.
Official Power Management References & Documentation
For more details on macOS power management, refer to the following developer resources:
- Apple Developer Documentation: Activity and Sleep Assertions Overview.
- macOS Manual Pages: Run
man pmsetorman caffeinatein your Terminal to read command-line specifications.
Windows Users: The Lid-Closed Action
If you are developing on Windows, the situation is different. Windows does not have equivalents to Amphetamine. The standard way to keep Windows awake is by going to Control Panel, editing the power plan, and changing "When I close the lid" to "Do Nothing". However, doing this manually is annoying and offers zero battery warnings when unplugged. **LidOrbit** is the only keep-awake utility on this list that works natively on Windows, toggling registry settings and standby limits automatically with a single click.
Frequently Asked Questions
Arm Your Agents. Close Your Lid.
Get the safest, most reliable keep-awake utility built for AI developers and automation engineers.