From 1c825797be7d20679dcea6133633964c5b30c2fc Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Mon, 1 Apr 2024 20:21:38 -0700 Subject: [PATCH] manager: Implement wifi_power_management_state --- src/manager.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/manager.rs b/src/manager.rs index 529cb58..2988690 100644 --- a/src/manager.rs +++ b/src/manager.rs @@ -99,9 +99,19 @@ impl SteamOSManager { } #[zbus(property)] - fn wifi_power_management_state(&self) -> zbus::fdo::Result { - Err(zbus::fdo::Error::UnknownProperty(String::from( - "This property can't currently be read", + async fn wifi_power_management_state(&self) -> zbus::fdo::Result { + let output = script_output("/usr/bin/iwconfig", &["wlan0"]) + .await + .map_err(anyhow_to_zbus_fdo)?; + for line in output.lines() { + return Ok(match line.trim() { + "Power Management:on" => WifiPowerManagement::Enabled as u32, + "Power Management:off" => WifiPowerManagement::Disabled as u32, + _ => continue, + }); + } + Err(zbus::fdo::Error::Failed(String::from( + "Failed to query power management state", ))) }