Re-enable notification on anime power-state change

This commit is contained in:
Luke D. Jones
2022-06-06 18:18:35 +12:00
parent 6e872ecab9
commit 5c0ad3e590

View File

@@ -68,24 +68,29 @@ impl CtrlAnimeZbus {
} }
/// Set whether the AniMe is displaying images/data /// Set whether the AniMe is displaying images/data
fn set_on_off(&self, status: bool) { async fn set_on_off(&self, #[zbus(signal_context)] ctxt: SignalContext<'_>, status: bool) {
let mut states = None;
'outer: loop { 'outer: loop {
if let Ok(mut lock) = self.0.try_lock() { if let Ok(mut lock) = self.0.try_lock() {
lock.write_bytes(&pkt_for_set_on(status)); lock.write_bytes(&pkt_for_set_on(status));
lock.config.awake_enabled = status; lock.config.awake_enabled = status;
lock.config.write(); lock.config.write();
// let states = AnimePowerStates { states = Some(AnimePowerStates {
// enabled: lock.config.awake_enabled, enabled: lock.config.awake_enabled,
// boot_anim_enabled: lock.config.boot_anim_enabled, boot_anim_enabled: lock.config.boot_anim_enabled,
// }; });
break 'outer; break 'outer;
} }
} }
if let Some(state) = states {
Self::notify_power_states(&ctxt, state).await.ok();
}
} }
/// Set whether the AniMe will show boot, suspend, or off animations /// Set whether the AniMe will show boot, suspend, or off animations
fn set_boot_on_off(&self, on: bool) { async fn set_boot_on_off(&self, #[zbus(signal_context)] ctxt: SignalContext<'_>, on: bool) {
let mut states = None;
'outer: loop { 'outer: loop {
if let Ok(mut lock) = self.0.try_lock() { if let Ok(mut lock) = self.0.try_lock() {
lock.write_bytes(&pkt_for_set_boot(on)); lock.write_bytes(&pkt_for_set_boot(on));
@@ -93,13 +98,16 @@ impl CtrlAnimeZbus {
lock.config.boot_anim_enabled = on; lock.config.boot_anim_enabled = on;
lock.config.write(); lock.config.write();
// let states = AnimePowerStates { states = Some(AnimePowerStates {
// enabled: lock.config.awake_enabled, enabled: lock.config.awake_enabled,
// boot_anim_enabled: lock.config.boot_anim_enabled, boot_anim_enabled: lock.config.boot_anim_enabled,
// }; });
break 'outer; break 'outer;
} }
} }
if let Some(state) = states {
Self::notify_power_states(&ctxt, state).await.ok();
}
} }
/// The main loop is the base system set action if the user isn't running /// The main loop is the base system set action if the user isn't running
@@ -116,7 +124,7 @@ impl CtrlAnimeZbus {
} }
} }
/// Get status of if the AniMe LEDs are on /// Get status of if the AniMe LEDs are on/displaying while system is awake
#[dbus_interface(property)] #[dbus_interface(property)]
fn awake_enabled(&self) -> bool { fn awake_enabled(&self) -> bool {
if let Ok(ctrl) = self.0.try_lock() { if let Ok(ctrl) = self.0.try_lock() {