| Crates.io | lid-angle |
| lib.rs | lid-angle |
| version | 0.1.1 |
| created_at | 2025-12-31 14:02:05.591865+00 |
| updated_at | 2025-12-31 17:59:12.644875+00 |
| description | A Rust CLI tool to read and display real-time MacBook lid angle |
| homepage | https://github.com/wangfu91/lid-angle-rs |
| repository | https://github.com/wangfu91/lid-angle-rs |
| max_upload_size | |
| id | 2014769 |
| size | 22,497 |
A Rust command-line tool to read and display your MacBook's hidden lid angle sensor in real-time.
This tool uses the IOKit HID framework to access the MacBook's built-in lid angle sensor and displays the current angle of your laptop's lid in real-time in the terminal.
cargo install lid-angle
git clone https://github.com/wangfu91/lid-angle-rs.git
cd lid-angle-rs
cargo build --release
The compiled binary will be available at target/release/lid-angle (or run with cargo run --release during development).
Simply run the tool:
Install once, then run:
lid-angle
The tool will:
Press Ctrl+C to exit.
MacBook Lid Angle Sensor Reader
================================
Searching for lid angle sensor...
✓ Lid angle sensor found and opened
Reading lid angle in real-time (press Ctrl+C to exit)...
Lid Angle: 125.43° [█████████████████████████████████████ ]
This tool interfaces with macOS's IOKit HID framework to access the lid angle sensor. The sensor is exposed as a HID device with the following properties:
The implementation is based on reverse-engineering work from the LidAngleSensor Objective-C project.
If you see this error:
Check device compatibility: Run the diagnostic command:
hidutil list --matching '{"VendorID":0x05AC,"ProductID":0x8104,"PrimaryUsagePage":32,"PrimaryUsage":138}'
If this returns no devices, your MacBook may not have the sensor.
Try with elevated privileges:
sudo lid-angle
Verify your MacBook model: The sensor is typically available on MacBook Pro models from 2019 onwards.
If you encounter permission errors, run the tool with sudo:
sudo lid-angle
This project was inspired by and based on the research from:
The tool uses the following Rust crates:
core-foundation and core-foundation-sys: For CoreFoundation types and bindingsThe lid angle sensor reports values as 16-bit integers in units of 0.01 degrees, providing a range from 0° (closed) to ~180° (fully open).
MIT License - see LICENSE file for details.
Contributions are welcome! Please feel free to submit issues or pull requests.