https://github.com/mishamyrt/lidoff
💡 Third state for the MacBook lid
https://github.com/mishamyrt/lidoff
automation daemon macos
Last synced: about 2 months ago
JSON representation
💡 Third state for the MacBook lid
- Host: GitHub
- URL: https://github.com/mishamyrt/lidoff
- Owner: mishamyrt
- License: mit
- Created: 2026-01-24T18:11:22.000Z (5 months ago)
- Default Branch: master
- Last Pushed: 2026-05-13T18:48:53.000Z (about 2 months ago)
- Last Synced: 2026-05-13T20:30:53.230Z (about 2 months ago)
- Topics: automation, daemon, macos
- Language: Objective-C
- Homepage:
- Size: 459 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Agents: AGENTS.md
Awesome Lists containing this project
README
`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`.
## Why
`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.
## Features
- 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 `caffeinate` session 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.
## Requirements
- MacBook Air or MacBook Pro with Apple Silicon (M2, M3, or M4).
- macOS with access to the built-in lid angle sensor.
## Installation
### Homebrew
```bash
brew install mishamyrt/tap/lidoff
lidoff install
```
### Quick Install
```bash
curl -fsSL https://raw.githubusercontent.com/mishamyrt/lidoff/master/install.sh | bash
lidoff install
```
The quick installer places the binary in `~/.local/bin`. Make sure that directory is in your `PATH`.
### From Source
```bash
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 install
```
## Usage
```text
lidoff [OPTIONS]
Commands:
install Install service as launch agent
uninstall Uninstall service's launch agent
run Start the monitor in the foreground
Options:
-t, --threshold Lid angle threshold in range 10-60 degrees [default: 30]
-i, --interval 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:
```bash
# 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 uninstall
```
## Behavior
`lidoff` 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 starts `caffeinate`.
- **Open**: `angle >= threshold`. Restores saved brightness values, restores external displays, and stops `caffeinate`.
- **Fully closed**: `angle < 5°`. Restores saved brightness values, restores external displays, and stops `caffeinate`, 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.
## Development
The project is a Rust workspace under `crates/`:
- `crates/lidoff` contains the CLI and LaunchAgent integration.
- `crates/lidoff-daemon` contains monitor state management and runtime orchestration.
- `crates/lidoff-display`, `crates/lidoff-lidsensor`, and `crates/lidoff-power` contain macOS integration shims.
Useful commands:
```bash
cargo build --workspace
make fmt
make lint
make test
make check
```
Development tools:
```bash
brew install llvm
rustup component add rustfmt clippy
```
## License
MIT