MacOS - How to keep your MacBook awake, even when the lid is closed.

First off, we're going to show you how to accomplish to keep your MacBook awake after closing the lid in two simple steps. After that, we're going to explain why this isn't a feature of our Mac app Caffeinated.

Step 1: Open Terminal

There are several ways to find and open Terminal on your Mac. One of the quickest and easiest ways to open it is with Spotlight Search.

  1. You can use the keyboard shortcut Command + Space to open Spotlight Search on your Mac. Or click on the Spotlight Search button in your menu bar.

  2. Type in "Terminal".

  3. You should see the Terminal application under Top Hit at the top of your results. Double-click it and Terminal will open.

Step 2: Run Command

There are essentially two commands you will need. One for keeping your MacBook awake (even with the lid closed) and the second one you'll use whenever you'd like to let your MacBook sleep again.

Note: Keeping your MacBook running while the lid is closed, will potentially trap heat between the display and the keyboard of your MacBook.

1) Command to deactivate Lid-Sleep (keep system awake,开启合盖不休眠模式)

javascript 复制代码
sudo pmset -b sleep 0; sudo pmset -b disablesleep 1

2) Command to activate Lid-Sleep (let system sleep again, like normal,关闭合盖不休眠模式)

bash 复制代码
sudo pmset -b sleep 5; sudo pmset -b disablesleep 0

Simply copy the desired command from above and paste it in Terminal. Hit Enter . Since these commands are sudo commands, they require your password to run. Therefore, simply enter your password and hit Enter again. Voilà! That's how to keep MacBook awake with lid closed.

Why is this not a feature of Caffeinated?

Well, we would love to implement this feature, but for now it's simply not possible due to Apple's guidelines and restrictions for apps available on the App Store.

These limitations are not a bad thing, as they help preventing harmful software (malware) on your Mac. Apple tries to keep the system safe and clean. Even though this comes with limitations for us developers, we appreciate this, especially from a users perspective.

相关推荐
pumpkin845149 小时前
Mac Studio M4 Max 纯本地化部署 Qwen 3.6 并桥接 Claude Code 实践指南
macos
hurrycry_小亦11 小时前
苹果WWDC 2026前瞻:Ferret-Pro端侧大模型即将亮相|小亦之闻|AI 编程三日速递!(5月26日~5月28日)
macos·ios·wwdc
搬砖的小码农_Sky14 小时前
macOS Sequoia OpenClaw + Ollama 本地离线部署(免API、Apple Silicon金属加速)
人工智能·macos·ai·人机交互
稚枭天卓18 小时前
mac 安装 redis
redis·macos
AugustRed18 小时前
MacOS 运维常用命令大全(超全速查表)
运维·macos
稚枭天卓1 天前
mac 安装mysql
mysql·macos
m0_535817552 天前
macOS上Claude Code安装配置保姆级教程:国内直连API,从0到1跑通(附避坑指南)
gpt·macos·ai·node.js·claude·claudecode·88api
我有满天星辰2 天前
Mac 安装 Redis + Spring Boot 整合 Redis(完整实战指南)
spring boot·redis·macos
游戏开发爱好者82 天前
iOS开发工具推荐:Xcode、AppCode、SwiftLint使用心得与效率提升
ide·vscode·macos·ios·个人开发·xcode·敏捷流程
whyfail2 天前
Codex 下载安装指南:Windows 和 macOS 官方版下载
windows·macos·codex