From edfbfde13b12b60d0ee07eb28ce852607cc784ef Mon Sep 17 00:00:00 2001 From: "Luke D. Jones" Date: Tue, 7 Jun 2022 12:08:18 +1200 Subject: [PATCH] Re-enable notif for profile change --- daemon/src/ctrl_profiles/zbus.rs | 34 ++++++++++++++++---------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/daemon/src/ctrl_profiles/zbus.rs b/daemon/src/ctrl_profiles/zbus.rs index 3282c519..b3d4b317 100644 --- a/daemon/src/ctrl_profiles/zbus.rs +++ b/daemon/src/ctrl_profiles/zbus.rs @@ -39,13 +39,17 @@ impl ProfileZbus { /// Toggle to next platform_profile. Names provided by `Profiles`. /// If fan-curves are supported will also activate a fan curve for profile. - fn next_profile(&mut self) { + async fn next_profile(&mut self, #[zbus(signal_context)] ctxt: SignalContext<'_>) { + let mut profile = None; if let Ok(mut ctrl) = self.inner.try_lock() { ctrl.set_next_profile() .unwrap_or_else(|err| warn!("{}", err)); ctrl.save_config(); + profile = Some(ctrl.config.active_profile); + } + if let Some(profile) = profile { + Self::notify_profile(&ctxt, profile).await.ok(); } - self.do_notification(); } /// Fetch the active profile name @@ -60,7 +64,12 @@ impl ProfileZbus { } /// Set this platform_profile name as active - fn set_active_profile(&self, profile: Profile) { + async fn set_active_profile( + &self, + #[zbus(signal_context)] ctxt: SignalContext<'_>, + profile: Profile, + ) { + let mut tmp = None; if let Ok(mut ctrl) = self.inner.try_lock() { // Read first just incase the user has modified the config before calling this ctrl.config.read(); @@ -73,8 +82,11 @@ impl ProfileZbus { .ok(); ctrl.save_config(); + tmp = Some(ctrl.config.active_profile); + } + if let Some(profile) = tmp { + Self::notify_profile(&ctxt, profile).await.ok(); } - self.do_notification(); } /// Get a list of profiles that have fan-curves enabled. @@ -163,19 +175,7 @@ impl ProfileZbus { } #[dbus_interface(signal)] - async fn notify_profile( - signal_ctxt: &SignalContext<'_>, - profile: &Profile, - ) -> zbus::Result<()> { - } -} - -impl ProfileZbus { - fn do_notification(&self) { - if let Ok(_ctrl) = self.inner.try_lock() { - // self.notify_profile(&ctrl.config.active_profile) - // .unwrap_or_else(|err| warn!("{}", err)); - } + async fn notify_profile(signal_ctxt: &SignalContext<'_>, profile: Profile) -> zbus::Result<()> { } }