git clone https://garage44.eu/jeroen/pinnacle.git.. /ui/src/brightness.rs
//! The screen's brightness as Settings keeps it: a percent in
//! `/settings/brightness`, which the display server gives the kernel at
//! start, as the volume (`sound`).
/// Where the brightness is kept.
pub const BRIGHTNESS_PATH: &str = "system:/settings/brightness";
/// The brightness kept, when one is: a percent, 0 to 100 (the kernel sets
/// no less than 5).
pub fn kept() -> Option<u8> {
pinnacle_rt::fs::read_string(BRIGHTNESS_PATH)?
.trim()
.parse()
.ok()
.filter(|v| *v <= 100)
}
/// Keeps `percent` where [`kept`] finds it.
pub fn keep(percent: u8) -> bool {
pinnacle_rt::fs::write(BRIGHTNESS_PATH, alloc::format!("{percent}").as_bytes())
}