Forwarded error from ProfileProxy::profile_names instead of 'expecting' there. Handled error up in main by logging. Reorganized code in ctrl_fan_cpu to keep consistent code structure

This commit is contained in:
Tony
2021-03-17 01:50:16 +00:00
committed by Luke Jones
parent c29afaf751
commit ad150903af
4 changed files with 34 additions and 0 deletions

View File

@@ -127,8 +127,28 @@ impl DbusFanAndCpu {
"Failed".to_string()
}
fn profile_names(&self) -> String {
if let Ok(ctrl) = self.inner.try_lock() {
if let Ok(mut cfg) = ctrl.config.try_lock() {
cfg.read();
let profile_names: String = cfg
.power_profiles
.keys()
.cloned()
.collect::<Vec<String>>()
.join(", ");
return profile_names;
}
}
"Failed".to_string()
}
#[dbus_interface(signal)]
fn notify_profile(&self, profile: &str) -> zbus::Result<()> {}
}
impl crate::ZbusAdd for DbusFanAndCpu {