| Crates.io | brightness |
| lib.rs | brightness |
| version | 0.8.0 |
| created_at | 2021-07-28 05:03:50.871185+00 |
| updated_at | 2025-09-02 05:04:08.660026+00 |
| description | Get and set display brightness |
| homepage | https://github.com/stephaneyfx/brightness |
| repository | https://github.com/stephaneyfx/brightness.git |
| max_upload_size | |
| id | 428185 |
| size | 80,805 |
This crate provides definitions to get and set display brightness.
Linux and Windows are supported.
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
}
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).
All contributions shall be licensed under the 0BSD license.