feat: persist fan curve when toggling fan control, avoid applying fan settings when there is no fan

This commit is contained in:
Ilya Zlobintsev
2023-02-20 08:44:19 +02:00
parent 6ec725ffd5
commit ede4886da9
5 changed files with 47 additions and 43 deletions

View File

@@ -315,16 +315,17 @@ impl App {
.context("Failed to set power profile")?;
}
let thermals_settings = self.root_stack.thermals_page.get_thermals_settings();
debug!("applying thermal settings: {thermals_settings:?}");
if let Some(thermals_settings) = self.root_stack.thermals_page.get_thermals_settings() {
debug!("applying thermal settings: {thermals_settings:?}");
self.daemon_client
.set_fan_control(
&gpu_id,
thermals_settings.manual_fan_control,
thermals_settings.curve,
)
.context("Could not set fan control")?;
self.daemon_client
.set_fan_control(
&gpu_id,
thermals_settings.manual_fan_control,
thermals_settings.curve,
)
.context("Could not set fan control")?;
}
self.set_initial(&gpu_id);

View File

@@ -176,7 +176,7 @@ fn show_list_window(title: &str, items: &[FeatureModel]) {
.build();
let base_model = gio::ListStore::new(FeatureModel::static_type());
base_model.extend_from_slice(&items);
base_model.extend_from_slice(items);
let expression = PropertyExpression::new(FeatureModel::static_type(), Expression::NONE, "name");
let filter = StringFilter::builder()

View File

@@ -181,17 +181,18 @@ impl ThermalsPage {
});
}
pub fn get_thermals_settings(&self) -> ThermalsSettings {
let manual_fan_control = !self.fan_control_enabled_switch.state();
let curve = if manual_fan_control {
Some(self.fan_curve_frame.get_curve())
pub fn get_thermals_settings(&self) -> Option<ThermalsSettings> {
if self.fan_control_enabled_switch.is_sensitive() {
let manual_fan_control = !self.fan_control_enabled_switch.state();
let curve = self.fan_curve_frame.get_curve();
let curve = if curve.is_empty() { None } else { Some(curve) };
Some(ThermalsSettings {
manual_fan_control,
curve,
})
} else {
None
};
ThermalsSettings {
manual_fan_control,
curve,
}
}
}