diff --git a/src/manager.rs b/src/manager.rs index 4202588..a51240a 100644 --- a/src/manager.rs +++ b/src/manager.rs @@ -128,10 +128,17 @@ impl SteamOSManager { } #[zbus(property)] - fn fan_control_state(&self) -> zbus::fdo::Result { - Err(zbus::fdo::Error::UnknownProperty(String::from( - "This property can't currently be read", - ))) + async fn fan_control_state(&self) -> zbus::fdo::Result { + 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)] diff --git a/src/systemd.rs b/src/systemd.rs index e8d4395..6c111f5 100644 --- a/src/systemd.rs +++ b/src/systemd.rs @@ -69,4 +69,8 @@ impl<'dbus> SystemdUnit<'dbus> { self.proxy.stop("fail").await?; Ok(()) } + + pub async fn active(&self) -> Result { + Ok(self.proxy.active_state().await? == "active") + } }