A macOS menu bar app that does one thing: toggle lid sleep.
Click the icon to keep your Mac awake with the lid closed. Click it again to go back to normal.
🌙 lid sleep on (normal) · ☕️ lid sleep off (stays awake)
No dependencies, no background polling, no preferences. ~100 lines of Swift.
curl -fsSL https://raw.githubusercontent.com/rafa-rrayes/LidLock/refs/heads/master/install.sh | bashRequires macOS 11+ and Xcode Command Line Tools (xcode-select --install).
The installer asks for your password once to add a sudo rule, then builds the app into ~/Applications/LidLock.app and launches it.
To start it automatically: System Settings → General → Login Items → add LidLock.
- Left click — toggle lid sleep
- Right click — current state and Quit
The app shells out to two commands:
sudo pmset -a disablesleep 1 # lid sleep off
sudo pmset -a disablesleep 0 # lid sleep onpmset needs root, so the installer writes /etc/sudoers.d/lidlock granting passwordless sudo for those two exact command lines only — no wildcards, no other arguments, nothing else escalated. On launch the app reads the live state from pmset -g, so the icon is never stale.
sudo pmset -a disablesleep 0
rm -rf ~/Applications/LidLock.app
sudo rm /etc/sudoers.d/lidlockgit clone https://github.com/rafa-rrayes/lidlock.git
cd lidlock
./install.shbuild.sh alone recompiles without touching the sudo rule.
- Disabling lid sleep means a closed Mac in a bag can get hot. Toggle it back off when you're done.
- The app is ad-hoc signed locally, not notarized — you built it yourself, so Gatekeeper stays out of the way.
MIT