lidoff is a macOS daemon for Apple Silicon MacBooks. It watches the lid angle, turns off the built-in display and keyboard backlight when the lid is partially closed, disables external displays, and keeps the machine awake with caffeinate.
lidoff is useful when you want the MacBook to keep working with the lid nearly closed:
- Run a long refactoring or LLM coding session while you step away.
- Keep audio playing without lighting the room.
- Leave a download, build, or sync running overnight.
The idea is to add a middle state between "open" and "closed": when the lid is only partially closed, the laptop stays awake but the displays and keyboard backlight are dimmed to zero.
demo.mp4
- Reads the MacBook lid angle instead of relying only on open/closed state.
- Dims the built-in display and keyboard backlight to zero when the lid is partially closed.
- Starts a
caffeinatesession while the partial-close state is active. - Restores saved brightness values when the lid opens or fully closes.
- Disables and restores external displays when possible.
- Installs as a per-user macOS LaunchAgent.
- MacBook Air or MacBook Pro with Apple Silicon (M2, M3, or M4).
- macOS with access to the built-in lid angle sensor.
brew install mishamyrt/tap/lidoff
lidoff installcurl -fsSL https://raw.githubusercontent.com/mishamyrt/lidoff/master/install.sh | bash
lidoff installThe quick installer places the binary in ~/.local/bin. Make sure that directory is in your PATH.
git clone https://github.com/mishamyrt/lidoff.git
cd lidoff
rustup toolchain install stable
cargo build --release --package lidoff
mkdir -p "$HOME/.local/bin"
install -m 755 target/release/lidoff "$HOME/.local/bin/lidoff"
lidoff installlidoff [OPTIONS] <COMMAND>
Commands:
install Install service as launch agent
uninstall Uninstall service's launch agent
run Start the monitor in the foreground
Options:
-t, --threshold <degrees> Lid angle threshold in range 10-60 degrees [default: 30]
-i, --interval <ms> Polling interval in ms in range 50-5000 ms [default: 300]
-v, --verbose Log current lid angle
-h, --help Print help
-V, --version Print version
Options are global and must be passed before the command:
# Run in the foreground with default settings
lidoff run
# Run in the foreground and print lid angle updates
lidoff --verbose run
# Install LaunchAgent with a custom threshold and polling interval
lidoff --threshold 25 --interval 500 install
# Remove the LaunchAgent
lidoff uninstalllidoff classifies lid angle into three states:
- Partially closed:
5° <= angle < threshold. Saves current brightness values, dims the built-in display and keyboard backlight to zero, disables external displays when possible, and startscaffeinate. - Open:
angle >= threshold. Restores saved brightness values, restores external displays, and stopscaffeinate. - Fully closed:
angle < 5°. Restores saved brightness values, restores external displays, and stopscaffeinate, allowing normal sleep behavior.
External display shutdown uses the available macOS display controls and falls back where possible. Some monitors or connection types may not support full external brightness control.
The project is a Rust workspace under crates/:
crates/lidoffcontains the CLI and LaunchAgent integration.crates/lidoff-daemoncontains monitor state management and runtime orchestration.crates/lidoff-display,crates/lidoff-lidsensor, andcrates/lidoff-powercontain macOS integration shims.
Useful commands:
cargo build --workspace
make fmt
make lint
make test
make checkDevelopment tools:
brew install llvm
rustup component add rustfmt clippyMIT