display-config-rs
A Rust crate for retrieving display configurations and observing changes (monitor plug/unplug, resolution changes, etc.) on Windows and macOS.
Features
- Get Display Info: Retrieve a list of connected displays with details like:
- ID (Platform specific)
- Logical Size
- Logical Position - Supports negative coordinates for multi-monitor setups.
- Scale Factor
- Primary status
- Mirroring status
- Observe Changes: Listen for display configuration events in real-time:
Added: A new display was connected.Removed: A display was disconnected.SizeChanged: Display size changed.OriginChanged: Display position changed (e.g., rearranged in settings).Mirrored/UnMirrored: Mirroring settings changed.
- Cross-Platform: Unified API for Windows and macOS.
Examples
List Displays
use get_displays;
Observe Changes
use ;
Platform Support
| Platform | Status | Notes |
|---|---|---|
| Windows | ✅ Supported | Uses EnumDisplayMonitors and WM_DISPLAYCHANGE. Requires Windows 8.1+ for per-monitor DPI awareness. |
| macOS | ✅ Supported | Uses CoreGraphics for display info and callbacks. |
| Linux | ❌ Not Supported | Planned for future release. |
License
This project is licensed under the MIT License.