#ddc-ci #ddc #cross-platform #linux

ddc-enhanced-rs

DDC/CI high level library for Rust (cross platform)

29 releases (stable)

1.2.7 Jun 19, 2022
1.2.0 Jun 18, 2022
1.1.2 Apr 18, 2022
0.1.5 Apr 16, 2022
0.1.1 Mar 30, 2022

#10 in #ddc

MIT license

18KB
419 lines

ddc-enhanced-rs

ddc-enhanced-rs is a cross platform Rust crate and Node package for controlling monitors with DDC/CI.

Documentation

Rust: https://docs.rs/ddc-enhanced-rs

NodeJS: https://github.com/ThalusA/ddc-enhanced-rs/blob/master/index.d.ts

Examples

Rust

use ddc_enhanced_rs::{get_enhanced_displays, get_brightness,
                      set_brightness, does_display_support_ddc};

// index in array is the id of the display
fn main() -> Result<(), std::io::Error> {
    for id in 0..get_enhanced_displays(false)?.len() {
        let value = get_brightness(id)?.value();
        set_brightness(id, value + 2).unwrap();
    }
    Ok(())
}

NodeJS

import Display from "ddc-enhanced-rs";

for (const display_info of Display.info()) {
    const display = new Display(display_info.id);
    const { value } = display.get_brightness();
    display.set_brightness(value + 2);
}

Dependencies

~2.4–3.5MB
~74K SLoC