bugfix: fix profile fan modes and creating

This commit is contained in:
Luke D. Jones
2021-05-26 09:24:18 +12:00
parent b2dc610c0b
commit 36bba75c50
7 changed files with 25 additions and 18 deletions

View File

@@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
# [3.6.1] - 2021-05-25
### Changed
- Bugfix: write correct fan modes for profiles
- Bugfix: apply created profiles
# [3.6.1] - 2021-05-25 # [3.6.1] - 2021-05-25
### Changed ### Changed
- Bugfix for cycling through profiles - Bugfix for cycling through profiles

2
Cargo.lock generated
View File

@@ -207,7 +207,7 @@ dependencies = [
[[package]] [[package]]
name = "daemon" name = "daemon"
version = "3.6.1" version = "3.6.2"
dependencies = [ dependencies = [
"env_logger", "env_logger",
"log", "log",

View File

@@ -473,8 +473,8 @@ fn handle_profile(
} }
if cmd.profiles_data { if cmd.profiles_data {
println!("Profiles:"); println!("Profiles:");
for s in dbus.proxies().profile().all_profile_data()?.lines() { for s in dbus.proxies().profile().all_profile_data()? {
println!("{}", s); println!("{:?}", s);
} }
} }

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "daemon" name = "daemon"
version = "3.6.1" version = "3.6.2"
license = "MPL-2.0" license = "MPL-2.0"
readme = "README.md" readme = "README.md"
authors = ["Luke <luke@ljones.dev>"] authors = ["Luke <luke@ljones.dev>"]

View File

@@ -69,12 +69,12 @@ impl CtrlFanAndCpu {
} }
pub(super) fn set_active(&mut self, profile: &str) -> Result<(), RogError> { pub(super) fn set_active(&mut self, profile: &str) -> Result<(), RogError> {
if let Ok(mut cfg) = self.config.clone().try_lock() { if let Ok(mut config) = self.config.clone().try_lock() {
cfg.read(); config.read();
if let Some(existing) = cfg.power_profiles.get(profile) { if let Some(existing) = config.power_profiles.get(profile) {
existing.set_system_all()?; existing.set_system_all()?;
cfg.active_profile = existing.name.clone(); config.active_profile = existing.name.clone();
cfg.write(); config.write();
info!("Profile was changed to: {}", profile); info!("Profile was changed to: {}", profile);
} }
} }
@@ -82,18 +82,20 @@ impl CtrlFanAndCpu {
} }
pub(super) fn new_or_modify(&mut self, profile: &Profile) -> Result<(), RogError> { pub(super) fn new_or_modify(&mut self, profile: &Profile) -> Result<(), RogError> {
if let Ok(mut cfg) = self.config.clone().try_lock() { if let Ok(mut config) = self.config.clone().try_lock() {
cfg.read(); config.read();
if let Some(existing) = cfg.power_profiles.get_mut(&profile.name) { if let Some(existing) = config.power_profiles.get_mut(&profile.name) {
*existing = profile.clone(); *existing = profile.clone();
existing.set_system_all()?; existing.set_system_all()?;
} else { } else {
cfg.power_profiles config.power_profiles
.insert(profile.name.clone(), profile.clone()); .insert(profile.name.clone(), profile.clone());
profile.set_system_all()?;
} }
cfg.active_profile = profile.name.clone();
cfg.write(); config.active_profile = profile.name.clone();
config.write();
} }
Ok(()) Ok(())
} }

View File

@@ -39,7 +39,7 @@ trait Daemon {
fn active_data(&self) -> zbus::Result<Profile>; fn active_data(&self) -> zbus::Result<Profile>;
/// Profiles method /// Profiles method
fn profiles(&self) -> zbus::Result<String>; fn profiles(&self) -> zbus::Result<Vec<Profile>>;
/// ProfileNames method /// ProfileNames method
fn profile_names(&self) -> zbus::Result<Vec<String>>; fn profile_names(&self) -> zbus::Result<Vec<String>>;
@@ -78,7 +78,7 @@ impl<'a> ProfileProxy<'a> {
} }
#[inline] #[inline]
pub fn all_profile_data(&self) -> Result<String> { pub fn all_profile_data(&self) -> Result<Vec<Profile>> {
self.0.profiles() self.0.profiles()
} }

View File

@@ -112,7 +112,7 @@ impl Profile {
pub fn set_system_all(&self) -> Result<(), ProfileError> { pub fn set_system_all(&self) -> Result<(), ProfileError> {
self.set_system_pstate()?; self.set_system_pstate()?;
if !self.fan_curve.is_empty() { if self.fan_curve.is_empty() {
self.set_system_fan_mode()?; self.set_system_fan_mode()?;
} else { } else {
self.set_system_fan_curve()?; self.set_system_fan_curve()?;