macOS system utility, 2026
Lid Awake
Keeps a MacBook awake with the lid closed, but only while it is plugged in.
current=$(pmset -g | awk '/SleepDisabled/ {print $2}')
current=${current:-0}
if pmset -g ps | head -1 | grep -q "AC Power"; then
want=1
else
want=0
fi
[ "$current" = "$want" ] && exit 0
pmset -a disablesleep "$want"
logger -t lid-awake-on-ac "disablesleep -> $want"
# Unplugged while the lid is already closed: sleep now rather than stay awake in a bag.
if [ "$want" = 0 ] && ioreg -r -k AppleClamshellState -d 4 | grep -q '"AppleClamshellState" = Yes'; then
pmset sleepnow
fiOverview
A small macOS utility with no app and no menu bar icon. On AC power, sleep is disabled, so closing the lid does not sleep the Mac. On battery, normal sleep comes back. If you unplug while the lid is already closed, the Mac sleeps right away instead of staying awake in your bag.
Engineering approach
- A root LaunchDaemon runs one short shell script every 10 seconds.
- The script changes nothing unless the wanted state differs from the current one.
- Both installer routes end at the same script, and a single command removes it all and restores normal sleep.
Every 10 seconds
- Read power source
- Compare with SleepDisabled
- Set disablesleep if different
- Unplugged and lid closed? Sleep now
Run the logic
Stack
POSIX shell, launchd, pmset, ioreg, pkgbuild
Technical challenges
Unplugging into a bag
- Problem
- Sleep stays disabled until something turns it back on, even with the lid shut on battery.
- Solution
- When power drops, the script reads the clamshell state from ioreg and calls pmset sleepnow if the lid is closed.
A root script must not be replaceable
- Problem
- launchd runs the script as root, so any user who can edit it gains root.
- Solution
- It installs into a root-only folder, /Library/PrivilegedHelperTools, not /usr/local/sbin, which is user-owned on Intel Homebrew Macs.
Installing without an app
- Problem
- People expect a double-click, but there is nothing to put in Applications.
- Solution
- A payload-free package whose postinstall step is the same install script used from source.
Outcome and status
Version 1.0.1 is released on GitHub as a package of about 2 KB.
Known limits
- The repo does not state a supported macOS range.
- The package is not signed by Apple, so macOS asks you to approve it in Privacy & Security.
- While plugged in, the Mac does not idle-sleep either.
- It does not watch temperature, and it conflicts with other tools that change disablesleep.