manager: Implement fan_control_state

This commit is contained in:
Vicki Pfau 2024-03-29 18:04:06 -07:00
parent 853ce3dd84
commit 406988fbdf
2 changed files with 15 additions and 4 deletions

View file

@ -128,10 +128,17 @@ impl SteamOSManager {
}
#[zbus(property)]
fn fan_control_state(&self) -> zbus::fdo::Result<u32> {
Err(zbus::fdo::Error::UnknownProperty(String::from(
"This property can't currently be read",
)))
async fn fan_control_state(&self) -> zbus::fdo::Result<u32> {
let jupiter_fan_control =
SystemdUnit::new(self.connection.clone(), "jupiter_2dfan_2dcontrol_2eservice")
.await
.map_err(anyhow_to_zbus_fdo)?;
let active = jupiter_fan_control.active().await
.map_err(anyhow_to_zbus_fdo)?;
Ok(match active {
true => FanControl::OS as u32,
false => FanControl::BIOS as u32,
})
}
#[zbus(property)]

View file

@ -69,4 +69,8 @@ impl<'dbus> SystemdUnit<'dbus> {
self.proxy.stop("fail").await?;
Ok(())
}
pub async fn active(&self) -> Result<bool> {
Ok(self.proxy.active_state().await? == "active")
}
}