Skip to content

li-kai/monitor-control

Repository files navigation

monitor-control

A macOS background agent that keeps a Dell U3225QE monitor's brightness in sync with the MacBook built-in display.

How it works

The agent polls the built-in panel brightness every 200 ms and writes the mapped value to the Dell monitor over DDC/CI. It only sends a write when the target brightness actually changes, keeping steady-state CPU and DDC traffic near zero.

Brightness is mapped through piecewise linear interpolation over measured calibration points rather than a naive linear scale, so perceived brightness stays matched across the range.

Building

Requires Rust (2024 edition) and macOS.

cargo build --release

Installation

A launchd plist is provided at launchd/dev.monitor-control.agent.plist. To install:

  1. Edit the plist and replace REPLACE_WITH_ABSOLUTE_BINARY_PATH with the path to the built binary.
  2. Copy it to ~/Library/LaunchAgents/.
  3. Load the agent:
launchctl load ~/Library/LaunchAgents/dev.monitor-control.agent.plist

The agent starts at login and launchd restarts it if it exits.

Recovery

The agent stays resident and recovers in place rather than exiting on failure:

  • If the built-in display is unavailable, it retries each poll cycle.
  • If the Dell monitor is unavailable or a DDC write fails, it backs off (1 s, 2 s, 4 s, capped at 5 s) and re-discovers the monitor.
  • Discovery and write failures track separate backoff streaks.

Logging

Set the log level with RUST_LOG (default: info). Logs go to stderr, which the plist routes to /tmp/monitor-control.stderr.log.

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors