diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a25f93e..f482bf4b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,12 +4,16 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [Unreleased 4.1.0] +## [Unreleased ] + +## [4.1.0] - 2022-06-20 ### Changed - Huge refactor to use zbus 2.2 + zvariant 3.0 in system-daemon. More work required. - Daemons with tasks not use `smol` for async ops. - Fixes to fan-curve settings from CLI (Author: Armas Span) - Add brightness to anime zbus notification +- Adjust how threads in AniMe matrix controller work +- Use proper power-state packet for keyboard LED's (Author: Martin Piffault) ### Added - Support for GA402R LED modes - Support for GU502LV LED modes @@ -17,7 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Support for G513IC LED modes (Author: dada513) - Support for G513QM LED modes (Author: Martin Piffault) - Add side-LED toggle support (Author: Martin Piffault) -- Support reloading keyboard brightness and mode on wake (from sleep/hiber) +- Support reloading keyboard mode on wake (from sleep/hiber) - Support reloading charge-level on wake (from sleep/hiber) - Support running AniMe animation blocks on wake/sleep and boot/shutdown events diff --git a/daemon/src/ctrl_aura/config.rs b/daemon/src/ctrl_aura/config.rs index a562b552..5302069e 100644 --- a/daemon/src/ctrl_aura/config.rs +++ b/daemon/src/ctrl_aura/config.rs @@ -1,6 +1,6 @@ use crate::laptops::LaptopLedData; use log::{error, info, warn}; -use rog_aura::{AuraEffect, AuraModeNum, AuraZone, LedBrightness}; +use rog_aura::{AuraEffect, AuraModeNum, AuraZone, LedBrightness, LedPowerStates}; use serde_derive::{Deserialize, Serialize}; use std::collections::BTreeMap; use std::fs::{File, OpenOptions}; @@ -8,30 +8,6 @@ use std::io::{Read, Write}; pub static AURA_CONFIG_PATH: &str = "/etc/asusd/aura.conf"; -#[derive(Deserialize, Serialize)] -pub struct AuraConfigV320 { - pub brightness: u32, - pub current_mode: AuraModeNum, - pub builtins: BTreeMap, - pub multizone: Option, -} - -impl AuraConfigV320 { - pub(crate) fn into_current(self) -> AuraConfig { - AuraConfig { - brightness: ::from(self.brightness), - current_mode: self.current_mode, - builtins: self.builtins, - multizone: self.multizone, - boot_anim_enabled: true, - sleep_anim_enabled: true, - all_leds_enabled: true, - keys_leds_enabled: true, - side_leds_enabled: true, - } - } -} - #[derive(Deserialize, Serialize)] pub struct AuraConfigV352 { pub brightness: LedBrightness, @@ -47,11 +23,13 @@ impl AuraConfigV352 { current_mode: self.current_mode, builtins: self.builtins, multizone: self.multizone, - boot_anim_enabled: true, - sleep_anim_enabled: true, - all_leds_enabled: true, - keys_leds_enabled: true, - side_leds_enabled: true, + power_states: LedPowerStates { + boot_anim: true, + sleep_anim: true, + all_leds: true, + keys_leds: true, + side_leds: true, + }, } } } @@ -74,11 +52,13 @@ impl AuraConfigV407 { current_mode: self.current_mode, builtins: self.builtins, multizone: self.multizone, - boot_anim_enabled: true, - sleep_anim_enabled: self.sleep_anim_enabled, - all_leds_enabled: self.awake_enabled, - keys_leds_enabled: self.awake_enabled, - side_leds_enabled: self.side_leds_enabled, + power_states: LedPowerStates { + boot_anim: true, + sleep_anim: self.sleep_anim_enabled, + all_leds: self.awake_enabled, + keys_leds: self.awake_enabled, + side_leds: self.side_leds_enabled, + }, } } } @@ -89,11 +69,7 @@ pub struct AuraConfig { pub current_mode: AuraModeNum, pub builtins: BTreeMap, pub multizone: Option, - pub boot_anim_enabled: bool, - pub sleep_anim_enabled: bool, - pub all_leds_enabled: bool, - pub keys_leds_enabled: bool, - pub side_leds_enabled: bool, + pub power_states: LedPowerStates, } impl Default for AuraConfig { @@ -103,11 +79,13 @@ impl Default for AuraConfig { current_mode: AuraModeNum::Static, builtins: BTreeMap::new(), multizone: None, - boot_anim_enabled: true, - sleep_anim_enabled: true, - all_leds_enabled: true, - keys_leds_enabled: true, - side_leds_enabled: true, + power_states: LedPowerStates { + boot_anim: true, + sleep_anim: true, + all_leds: true, + keys_leds: true, + side_leds: true, + }, } } } @@ -133,11 +111,6 @@ impl AuraConfig { } else { if let Ok(data) = serde_json::from_str(&buf) { return data; - } else if let Ok(data) = serde_json::from_str::(&buf) { - let config = data.into_current(); - config.write(); - info!("Updated AuraConfig version"); - return config; } else if let Ok(data) = serde_json::from_str::(&buf) { let config = data.into_current(); config.write(); diff --git a/daemon/src/ctrl_aura/controller.rs b/daemon/src/ctrl_aura/controller.rs index 6698d1f8..5a29eb28 100644 --- a/daemon/src/ctrl_aura/controller.rs +++ b/daemon/src/ctrl_aura/controller.rs @@ -183,7 +183,7 @@ impl CtrlKbdLed { match Self::find_led_node(prod) { Ok(node) => { led_node = Some(node); - info!("Found keyboard controller 0x{prod}"); + info!("Looked for keyboard controller 0x{prod}: Found"); break; } Err(err) => info!("Looked for keyboard controller 0x{prod}: {err}"), @@ -280,11 +280,11 @@ impl CtrlKbdLed { /// Set combination state for boot animation/sleep animation/all leds/keys leds/side leds LED active pub(super) fn set_power_states(&self, config: &AuraConfig) -> Result<(), RogError> { let bytes = leds_message( - config.boot_anim_enabled, - config.sleep_anim_enabled, - config.all_leds_enabled, - config.keys_leds_enabled, - config.side_leds_enabled, + config.power_states.boot_anim, + config.power_states.sleep_anim, + config.power_states.all_leds, + config.power_states.keys_leds, + config.power_states.side_leds, ); // Quite ugly, must be a more idiomatic way to do diff --git a/daemon/src/ctrl_aura/zbus.rs b/daemon/src/ctrl_aura/zbus.rs index 30c20ea3..c4847340 100644 --- a/daemon/src/ctrl_aura/zbus.rs +++ b/daemon/src/ctrl_aura/zbus.rs @@ -34,20 +34,14 @@ impl CtrlKbdLedZbus { ) { let mut states = None; if let Ok(mut ctrl) = self.0.try_lock() { - ctrl.config.boot_anim_enabled = enabled; + ctrl.config.power_states.boot_anim = enabled; ctrl.config.write(); ctrl.set_power_states(&ctrl.config) .map_err(|err| warn!("{}", err)) .ok(); - states = Some(LedPowerStates { - boot_anim: ctrl.config.boot_anim_enabled, - sleep_anim: ctrl.config.sleep_anim_enabled, - all_leds: ctrl.config.all_leds_enabled, - keys_leds: ctrl.config.keys_leds_enabled, - side_leds: ctrl.config.side_leds_enabled, - }); + states = Some(ctrl.config.power_states); } // Need to pull state out like this due to MutexGuard if let Some(states) = states { @@ -65,20 +59,14 @@ impl CtrlKbdLedZbus { ) { let mut states = None; if let Ok(mut ctrl) = self.0.try_lock() { - ctrl.config.sleep_anim_enabled = enabled; + ctrl.config.power_states.sleep_anim = enabled; ctrl.config.write(); ctrl.set_power_states(&ctrl.config) .map_err(|err| warn!("{}", err)) .ok(); - states = Some(LedPowerStates { - boot_anim: ctrl.config.boot_anim_enabled, - sleep_anim: ctrl.config.sleep_anim_enabled, - all_leds: ctrl.config.all_leds_enabled, - keys_leds: ctrl.config.keys_leds_enabled, - side_leds: ctrl.config.side_leds_enabled, - }); + states = Some(ctrl.config.power_states); } if let Some(states) = states { Self::notify_power_states(&ctxt, &states) @@ -95,22 +83,16 @@ impl CtrlKbdLedZbus { ) { let mut states = None; if let Ok(mut ctrl) = self.0.try_lock() { - ctrl.config.all_leds_enabled = enabled; - ctrl.config.keys_leds_enabled = enabled; - ctrl.config.side_leds_enabled = enabled; + ctrl.config.power_states.all_leds = enabled; + ctrl.config.power_states.keys_leds = enabled; + ctrl.config.power_states.side_leds = enabled; ctrl.config.write(); ctrl.set_power_states(&ctrl.config) .map_err(|err| warn!("{}", err)) .ok(); - states = Some(LedPowerStates { - boot_anim: ctrl.config.boot_anim_enabled, - sleep_anim: ctrl.config.sleep_anim_enabled, - all_leds: ctrl.config.all_leds_enabled, - keys_leds: ctrl.config.keys_leds_enabled, - side_leds: ctrl.config.side_leds_enabled, - }); + states = Some(ctrl.config.power_states); } // Need to pull state out like this due to MutexGuard if let Some(states) = states { @@ -128,20 +110,14 @@ impl CtrlKbdLedZbus { ) { let mut states = None; if let Ok(mut ctrl) = self.0.try_lock() { - ctrl.config.keys_leds_enabled = enabled; + ctrl.config.power_states.keys_leds = enabled; ctrl.config.write(); ctrl.set_power_states(&ctrl.config) .map_err(|err| warn!("{}", err)) .ok(); - states = Some(LedPowerStates { - boot_anim: ctrl.config.boot_anim_enabled, - sleep_anim: ctrl.config.sleep_anim_enabled, - all_leds: ctrl.config.all_leds_enabled, - keys_leds: ctrl.config.keys_leds_enabled, - side_leds: ctrl.config.side_leds_enabled, - }); + states = Some(ctrl.config.power_states); } // Need to pull state out like this due to MutexGuard if let Some(states) = states { @@ -159,20 +135,14 @@ impl CtrlKbdLedZbus { ) { let mut states = None; if let Ok(mut ctrl) = self.0.try_lock() { - ctrl.config.side_leds_enabled = enabled; + ctrl.config.power_states.side_leds = enabled; ctrl.config.write(); ctrl.set_power_states(&ctrl.config) .map_err(|err| warn!("{}", err)) .ok(); - states = Some(LedPowerStates { - boot_anim: ctrl.config.boot_anim_enabled, - sleep_anim: ctrl.config.sleep_anim_enabled, - all_leds: ctrl.config.all_leds_enabled, - keys_leds: ctrl.config.keys_leds_enabled, - side_leds: ctrl.config.side_leds_enabled, - }); + states = Some(ctrl.config.power_states); } // Need to pull state out like this due to MutexGuard if let Some(states) = states { @@ -258,7 +228,7 @@ impl CtrlKbdLedZbus { #[dbus_interface(property)] async fn boot_enabled(&self) -> bool { if let Ok(ctrl) = self.0.try_lock() { - return ctrl.config.boot_anim_enabled; + return ctrl.config.power_states.boot_anim; } true } @@ -266,7 +236,7 @@ impl CtrlKbdLedZbus { #[dbus_interface(property)] async fn sleep_enabled(&self) -> bool { if let Ok(ctrl) = self.0.try_lock() { - return ctrl.config.sleep_anim_enabled; + return ctrl.config.power_states.sleep_anim; } true } @@ -274,7 +244,7 @@ impl CtrlKbdLedZbus { #[dbus_interface(property)] async fn all_leds_enabled(&self) -> bool { if let Ok(ctrl) = self.0.try_lock() { - return ctrl.config.all_leds_enabled; + return ctrl.config.power_states.all_leds; } true } @@ -282,7 +252,7 @@ impl CtrlKbdLedZbus { #[dbus_interface(property)] async fn keys_leds_enabled(&self) -> bool { if let Ok(ctrl) = self.0.try_lock() { - return ctrl.config.keys_leds_enabled; + return ctrl.config.power_states.keys_leds; } true } @@ -290,7 +260,7 @@ impl CtrlKbdLedZbus { #[dbus_interface(property)] fn side_leds_enabled(&self) -> bool { if let Ok(ctrl) = self.0.try_lock() { - return ctrl.config.side_leds_enabled; + return ctrl.config.power_states.side_leds; } true }