English · Русский
LidSwitch is a tiny native macOS menu bar app that controls whether a running MacBook keeps working or goes to sleep when its lid is closed.
Website: pismenny.ru/lidswitch
Left-click the single laptop icon to switch the mode immediately:
- green screen with a number — the Mac keeps working with its lid closed; the number is the estimated battery runtime in hours
- yellow screen with
Zz— the Mac is allowed to sleep when its lid closes - gray screen with
?— managed lid control is not ready or confirmed
After each switch, a short popover confirms what the Mac will do. Right-click the icon to see the current state, refresh it, manage helper access, or quit.
The right-click menu also switches macOS Energy Mode between Low Power, Automatic, and High Power. A checkmark shows the active mode. LidSwitch applies the selection to both battery and power-adapter profiles.
The icon shows an estimated number of active hours with the lid closed, both on
battery and on AC power. The number is drawn inside the laptop screen, so the
menu bar item never grows wider. It appears only in the green state, when
closed-lid work is enabled; the yellow sleep state shows Zz instead.
On AC, LidSwitch uses the last learned battery consumption for the selected
Energy Mode; before it has learned one, it uses a conservative baseline model.
- A MacBook with Apple silicon
- macOS Sequoia 15 or later
brew install --cask dapi/tap/lidswitch
open /Applications/LidSwitch.appUpgrade later with brew upgrade --cask lidswitch.
- Download
LidSwitch-0.7.0-macos-arm64.zipfrom the latest release. - Unzip it and move
LidSwitch.appto/Applications. - Control-click the app in Finder, choose Open, then confirm Open.
The first public build is ad-hoc signed because it is not yet notarized with an Apple Developer ID. If macOS still blocks it after using Open, remove the download quarantine once and launch it again:
xattr -dr com.apple.quarantine /Applications/LidSwitch.app
open /Applications/LidSwitch.appVerify the downloaded archive against the .sha256 file attached to the same
GitHub release when integrity matters.
Full Xcode is not required. The Swift toolchain from Xcode Command Line Tools is enough.
git clone https://github.com/dapi/LidSwitch.git
cd LidSwitch
./Scripts/build-app.sh
mkdir -p ~/Applications
cp -R dist/LidSwitch.app ~/Applications/
open ~/Applications/LidSwitch.appmacOS asks for one-time approval of LidSwitch's embedded managed-lid daemon in Login Items. The daemon safely coordinates lid events and sleep. A separate narrow helper is used only when changing Energy Mode.
The installed helper is owned by root and accepts only a fixed allowlist of
operations: check its version or select one of the three energy modes. It does
not accept arbitrary shell commands or power
settings from the app. Right-click the icon and choose Remove passwordless
switching… to remove it and its permission.
Warning
Preventing sleep with the lid closed can drain the battery and generate heat.
Do not put a running MacBook into a bag or another enclosed space. Switch
LidSwitch to the yellow Zz state first.
The embedded root daemon owns the system-wide disablesleep setting only while
the app maintains an authenticated heartbeat lease. It observes clamshell
changes and tells the app to play Glass for continued work or Funk before
sleep. In sleep mode the app acknowledges sound completion; the daemon restores
native sleep and explicitly requests system sleep. If the app disconnects or a
deadline expires, the daemon restores native sleep first, so a closed Mac is not
left awake indefinitely.
The forecast uses a rolling median of live battery power measurements. With the lid open, it models closed-lid consumption by subtracting the internal display's brightness-dependent draw. If the Mac is already awake with its lid closed, it uses the directly measured power instead. The workload is assumed to remain similar, so the number changes as CPU/GPU activity changes.
On AC power, the battery reports no discharge rate. LidSwitch therefore stores the most recent predicted closed-lid wattage learned on battery and applies it to the current charge. Until the first battery measurement is available, it uses a mode-specific baseline: 6 W for Low Power, 8 W for Automatic, or 12 W for High Power. The menu identifies when a baseline is being used.
During one-time setup, LidSwitch installs the helper at
/Library/PrivilegedHelperTools/me.dapi.LidSwitch.Helper and validates a narrow
rule in /etc/sudoers.d/lidswitch. The rule permits only the current account to
run that root-owned helper without another password prompt.
swift run LidSwitchCoreChecks
swift run LidSwitchDaemonCoreChecks
swift run LidSwitchDaemonProtocolChecksSee QA.md for the automated coverage and the Apple silicon/macOS 15+ manual test matrix.
Create a release archive locally with:
./Scripts/package-release.sh