7 releases (4 breaking)

0.5.0 Sep 10, 2022
0.4.1 Jan 30, 2022
0.3.1 Nov 1, 2021
0.3.0 Sep 5, 2021
0.1.0 Jul 28, 2021

#397 in Unix APIs

Download history 23/week @ 2024-07-21 209/week @ 2024-07-28 161/week @ 2024-08-04 262/week @ 2024-08-11 245/week @ 2024-08-18 141/week @ 2024-08-25 230/week @ 2024-09-01 140/week @ 2024-09-08 304/week @ 2024-09-15 200/week @ 2024-09-22 89/week @ 2024-09-29 116/week @ 2024-10-06 125/week @ 2024-10-13 96/week @ 2024-10-20 25/week @ 2024-10-27 191/week @ 2024-11-03

440 downloads per month
Used in 2 crates

0BSD license

48KB
958 lines

Overview

This crate provides definitions to get and set display brightness.

Linux and Windows are supported.

Example

use brightness::Brightness;
use futures::TryStreamExt;

async fn show_brightness() -> Result<(), brightness::Error> {
    brightness::brightness_devices().try_for_each(|dev| async move {
        let name = dev.device_name().await?;
        let value = dev.get().await?;
        println!("Brightness of device {} is {}%", name, value);
        Ok(())
    }).await
}

Linux

This crate interacts with devices found at /sys/class/backlight. This means that the ddcci-backlight kernel driver is required to control external displays (via DDC/CI).

Setting brightness is attempted using D-Bus and logind, which requires systemd 243 or newer. If this fails because the method is not available, the desired brightness is written to /sys/class/backlight/$DEVICE/brightness, which requires permission (udev rules can help with that).

Contribute

All contributions shall be licensed under the 0BSD license.

Dependencies

~0.6–45MB
~670K SLoC