From daea1f538c19fc8bc1a8f4d1f391198c25509c9f Mon Sep 17 00:00:00 2001 From: Denis Benato Date: Wed, 8 Oct 2025 01:01:43 +0200 Subject: [PATCH 1/7] chore: cargo fmt --- asusctl/examples/anime-gif.rs | 13 +- asusd/src/asus_armoury.rs | 3 +- asusd/src/aura_laptop/config.rs | 124 ++++++++----------- rog-aura/src/effects/mod.rs | 8 +- rog-aura/src/keyboard/layouts.rs | 198 ++++++++++++++----------------- rog-platform/src/cpu.rs | 28 ++--- 6 files changed, 158 insertions(+), 216 deletions(-) diff --git a/asusctl/examples/anime-gif.rs b/asusctl/examples/anime-gif.rs index a205c1ac..847d04c6 100644 --- a/asusctl/examples/anime-gif.rs +++ b/asusctl/examples/anime-gif.rs @@ -21,14 +21,11 @@ fn main() { let brightness = args[2].parse::().unwrap(); let anime_type = get_anime_type(); let mut seq = Sequences::new(anime_type); - seq.insert( - 0, - &ActionLoader::AsusAnimation { - file: path.into(), - time: rog_anime::AnimTime::Infinite, - brightness, - }, - ) + seq.insert(0, &ActionLoader::AsusAnimation { + file: path.into(), + time: rog_anime::AnimTime::Infinite, + brightness, + }) .unwrap(); loop { diff --git a/asusd/src/asus_armoury.rs b/asusd/src/asus_armoury.rs index 71639b23..bb78130e 100644 --- a/asusd/src/asus_armoury.rs +++ b/asusd/src/asus_armoury.rs @@ -91,7 +91,8 @@ impl AsusArmouryAttribute { .await; } else { info!( - "inotify event stream failed for {} ({}). You can ignore this if unsupported", + "inotify event stream failed for {} ({}). You can ignore this \ + if unsupported", name, $attr_str ); } diff --git a/asusd/src/aura_laptop/config.rs b/asusd/src/aura_laptop/config.rs index 956f6a46..326602af 100644 --- a/asusd/src/aura_laptop/config.rs +++ b/asusd/src/aura_laptop/config.rs @@ -295,38 +295,26 @@ mod tests { let res = config.multizone.unwrap(); let sta = res.get(&AuraModeNum::Static).unwrap(); assert_eq!(sta.len(), 4); - assert_eq!( - sta[0].colour1, - Colour { - r: 0xff, - g: 0x00, - b: 0xff - } - ); - assert_eq!( - sta[1].colour1, - Colour { - r: 0x00, - g: 0xff, - b: 0xff - } - ); - assert_eq!( - sta[2].colour1, - Colour { - r: 0xff, - g: 0xff, - b: 0x00 - } - ); - assert_eq!( - sta[3].colour1, - Colour { - r: 0x00, - g: 0xff, - b: 0x00 - } - ); + assert_eq!(sta[0].colour1, Colour { + r: 0xff, + g: 0x00, + b: 0xff + }); + assert_eq!(sta[1].colour1, Colour { + r: 0x00, + g: 0xff, + b: 0xff + }); + assert_eq!(sta[2].colour1, Colour { + r: 0xff, + g: 0xff, + b: 0x00 + }); + assert_eq!(sta[3].colour1, Colour { + r: 0x00, + g: 0xff, + b: 0x00 + }); } #[test] @@ -384,28 +372,22 @@ mod tests { assert_eq!(config.brightness, LedBrightness::Med); assert_eq!(config.builtins.len(), 5); - assert_eq!( - config.builtins.first_entry().unwrap().get(), - &AuraEffect { - mode: AuraModeNum::Static, - zone: AuraZone::None, - colour1: Colour { r: 166, g: 0, b: 0 }, - colour2: Colour { r: 0, g: 0, b: 0 }, - speed: Speed::Med, - direction: Direction::Right - } - ); + assert_eq!(config.builtins.first_entry().unwrap().get(), &AuraEffect { + mode: AuraModeNum::Static, + zone: AuraZone::None, + colour1: Colour { r: 166, g: 0, b: 0 }, + colour2: Colour { r: 0, g: 0, b: 0 }, + speed: Speed::Med, + direction: Direction::Right + }); assert_eq!(config.enabled.states.len(), 1); - assert_eq!( - config.enabled.states[0], - AuraPowerState { - zone: PowerZones::KeyboardAndLightbar, - boot: true, - awake: true, - sleep: true, - shutdown: true - } - ); + assert_eq!(config.enabled.states[0], AuraPowerState { + zone: PowerZones::KeyboardAndLightbar, + boot: true, + awake: true, + sleep: true, + shutdown: true + }); } #[test] @@ -415,27 +397,21 @@ mod tests { assert_eq!(config.brightness, LedBrightness::Med); assert_eq!(config.builtins.len(), 12); - assert_eq!( - config.builtins.first_entry().unwrap().get(), - &AuraEffect { - mode: AuraModeNum::Static, - zone: AuraZone::None, - colour1: Colour { r: 166, g: 0, b: 0 }, - colour2: Colour { r: 0, g: 0, b: 0 }, - speed: Speed::Med, - direction: Direction::Right - } - ); + assert_eq!(config.builtins.first_entry().unwrap().get(), &AuraEffect { + mode: AuraModeNum::Static, + zone: AuraZone::None, + colour1: Colour { r: 166, g: 0, b: 0 }, + colour2: Colour { r: 0, g: 0, b: 0 }, + speed: Speed::Med, + direction: Direction::Right + }); assert_eq!(config.enabled.states.len(), 4); - assert_eq!( - config.enabled.states[0], - AuraPowerState { - zone: PowerZones::Keyboard, - boot: true, - awake: true, - sleep: true, - shutdown: true - } - ); + assert_eq!(config.enabled.states[0], AuraPowerState { + zone: PowerZones::Keyboard, + boot: true, + awake: true, + sleep: true, + shutdown: true + }); } } diff --git a/rog-aura/src/effects/mod.rs b/rog-aura/src/effects/mod.rs index 0fbc7cb9..5b3f2163 100644 --- a/rog-aura/src/effects/mod.rs +++ b/rog-aura/src/effects/mod.rs @@ -207,14 +207,12 @@ mod tests { fn single_key_next_state_then_create() { let layout = KeyLayout::default_layout(); let mut seq = AdvancedEffects::new(false); - seq.effects.push(Effect::Static(Static::new( - LedCode::F, - Colour { + seq.effects + .push(Effect::Static(Static::new(LedCode::F, Colour { r: 255, g: 127, b: 0, - }, - ))); + }))); seq.next_state(&layout); let packets = seq.create_packets(); diff --git a/rog-aura/src/keyboard/layouts.rs b/rog-aura/src/keyboard/layouts.rs index 4a363128..b3b3b91f 100644 --- a/rog-aura/src/keyboard/layouts.rs +++ b/rog-aura/src/keyboard/layouts.rs @@ -335,117 +335,93 @@ impl KeyLayout { KeyShape::new_led(1.0, 1.0, 0.1, 0.1, 0.1, 0.1), )]), key_rows: vec![ - KeyRow::new( - 0.1, - 0.1, - vec![ - (LedCode::Esc, "regular".to_owned()), - (LedCode::F1, "regular".to_owned()), - (LedCode::F2, "regular".to_owned()), - (LedCode::F3, "regular".to_owned()), - (LedCode::F4, "regular".to_owned()), - // not sure which key to put here - (LedCode::F5, "regular".to_owned()), - (LedCode::F6, "regular".to_owned()), - (LedCode::F7, "regular".to_owned()), - (LedCode::F8, "regular".to_owned()), - (LedCode::F9, "regular".to_owned()), - (LedCode::F10, "regular".to_owned()), - (LedCode::F11, "regular".to_owned()), - (LedCode::F12, "regular".to_owned()), - ], - ), - KeyRow::new( - 0.1, - 0.1, - vec![ - (LedCode::Tilde, "regular".to_owned()), - (LedCode::N1, "regular".to_owned()), - (LedCode::N2, "regular".to_owned()), - (LedCode::N3, "regular".to_owned()), - (LedCode::N4, "regular".to_owned()), - (LedCode::N5, "regular".to_owned()), - (LedCode::N6, "regular".to_owned()), - (LedCode::N7, "regular".to_owned()), - (LedCode::N8, "regular".to_owned()), - (LedCode::N9, "regular".to_owned()), - (LedCode::N0, "regular".to_owned()), - (LedCode::Hyphen, "regular".to_owned()), - (LedCode::Equals, "regular".to_owned()), - (LedCode::Backspace, "regular".to_owned()), - ], - ), - KeyRow::new( - 0.1, - 0.1, - vec![ - (LedCode::Tab, "regular".to_owned()), - (LedCode::Q, "regular".to_owned()), - (LedCode::W, "regular".to_owned()), - (LedCode::E, "regular".to_owned()), - (LedCode::R, "regular".to_owned()), - (LedCode::T, "regular".to_owned()), - (LedCode::Y, "regular".to_owned()), - (LedCode::U, "regular".to_owned()), - (LedCode::I, "regular".to_owned()), - (LedCode::O, "regular".to_owned()), - (LedCode::P, "regular".to_owned()), - (LedCode::LBracket, "regular".to_owned()), - (LedCode::RBracket, "regular".to_owned()), - (LedCode::BackSlash, "regular".to_owned()), - ], - ), - KeyRow::new( - 0.1, - 0.1, - vec![ - (LedCode::Caps, "regular".to_owned()), - (LedCode::A, "regular".to_owned()), - (LedCode::S, "regular".to_owned()), - (LedCode::D, "regular".to_owned()), - (LedCode::F, "regular".to_owned()), - (LedCode::G, "regular".to_owned()), - (LedCode::H, "regular".to_owned()), - (LedCode::J, "regular".to_owned()), - (LedCode::K, "regular".to_owned()), - (LedCode::L, "regular".to_owned()), - (LedCode::SemiColon, "regular".to_owned()), - (LedCode::Quote, "regular".to_owned()), - (LedCode::Return, "regular".to_owned()), - ], - ), - KeyRow::new( - 0.1, - 0.1, - vec![ - (LedCode::LShift, "regular".to_owned()), - (LedCode::Z, "regular".to_owned()), - (LedCode::X, "regular".to_owned()), - (LedCode::C, "regular".to_owned()), - (LedCode::V, "regular".to_owned()), - (LedCode::B, "regular".to_owned()), - (LedCode::N, "regular".to_owned()), - (LedCode::M, "regular".to_owned()), - (LedCode::Comma, "regular".to_owned()), - (LedCode::Period, "regular".to_owned()), - (LedCode::FwdSlash, "regular".to_owned()), - (LedCode::Rshift, "regular".to_owned()), - ], - ), - KeyRow::new( - 0.1, - 0.1, - vec![ - (LedCode::LCtrl, "regular".to_owned()), - (LedCode::LFn, "regular".to_owned()), - (LedCode::Meta, "regular".to_owned()), - (LedCode::LAlt, "regular".to_owned()), - (LedCode::Spacebar, "regular".to_owned()), - (LedCode::RAlt, "regular".to_owned()), - (LedCode::PrtSc, "regular".to_owned()), - (LedCode::RCtrl, "regular".to_owned()), - ], - ), + KeyRow::new(0.1, 0.1, vec![ + (LedCode::Esc, "regular".to_owned()), + (LedCode::F1, "regular".to_owned()), + (LedCode::F2, "regular".to_owned()), + (LedCode::F3, "regular".to_owned()), + (LedCode::F4, "regular".to_owned()), + // not sure which key to put here + (LedCode::F5, "regular".to_owned()), + (LedCode::F6, "regular".to_owned()), + (LedCode::F7, "regular".to_owned()), + (LedCode::F8, "regular".to_owned()), + (LedCode::F9, "regular".to_owned()), + (LedCode::F10, "regular".to_owned()), + (LedCode::F11, "regular".to_owned()), + (LedCode::F12, "regular".to_owned()), + ]), + KeyRow::new(0.1, 0.1, vec![ + (LedCode::Tilde, "regular".to_owned()), + (LedCode::N1, "regular".to_owned()), + (LedCode::N2, "regular".to_owned()), + (LedCode::N3, "regular".to_owned()), + (LedCode::N4, "regular".to_owned()), + (LedCode::N5, "regular".to_owned()), + (LedCode::N6, "regular".to_owned()), + (LedCode::N7, "regular".to_owned()), + (LedCode::N8, "regular".to_owned()), + (LedCode::N9, "regular".to_owned()), + (LedCode::N0, "regular".to_owned()), + (LedCode::Hyphen, "regular".to_owned()), + (LedCode::Equals, "regular".to_owned()), + (LedCode::Backspace, "regular".to_owned()), + ]), + KeyRow::new(0.1, 0.1, vec![ + (LedCode::Tab, "regular".to_owned()), + (LedCode::Q, "regular".to_owned()), + (LedCode::W, "regular".to_owned()), + (LedCode::E, "regular".to_owned()), + (LedCode::R, "regular".to_owned()), + (LedCode::T, "regular".to_owned()), + (LedCode::Y, "regular".to_owned()), + (LedCode::U, "regular".to_owned()), + (LedCode::I, "regular".to_owned()), + (LedCode::O, "regular".to_owned()), + (LedCode::P, "regular".to_owned()), + (LedCode::LBracket, "regular".to_owned()), + (LedCode::RBracket, "regular".to_owned()), + (LedCode::BackSlash, "regular".to_owned()), + ]), + KeyRow::new(0.1, 0.1, vec![ + (LedCode::Caps, "regular".to_owned()), + (LedCode::A, "regular".to_owned()), + (LedCode::S, "regular".to_owned()), + (LedCode::D, "regular".to_owned()), + (LedCode::F, "regular".to_owned()), + (LedCode::G, "regular".to_owned()), + (LedCode::H, "regular".to_owned()), + (LedCode::J, "regular".to_owned()), + (LedCode::K, "regular".to_owned()), + (LedCode::L, "regular".to_owned()), + (LedCode::SemiColon, "regular".to_owned()), + (LedCode::Quote, "regular".to_owned()), + (LedCode::Return, "regular".to_owned()), + ]), + KeyRow::new(0.1, 0.1, vec![ + (LedCode::LShift, "regular".to_owned()), + (LedCode::Z, "regular".to_owned()), + (LedCode::X, "regular".to_owned()), + (LedCode::C, "regular".to_owned()), + (LedCode::V, "regular".to_owned()), + (LedCode::B, "regular".to_owned()), + (LedCode::N, "regular".to_owned()), + (LedCode::M, "regular".to_owned()), + (LedCode::Comma, "regular".to_owned()), + (LedCode::Period, "regular".to_owned()), + (LedCode::FwdSlash, "regular".to_owned()), + (LedCode::Rshift, "regular".to_owned()), + ]), + KeyRow::new(0.1, 0.1, vec![ + (LedCode::LCtrl, "regular".to_owned()), + (LedCode::LFn, "regular".to_owned()), + (LedCode::Meta, "regular".to_owned()), + (LedCode::LAlt, "regular".to_owned()), + (LedCode::Spacebar, "regular".to_owned()), + (LedCode::RAlt, "regular".to_owned()), + (LedCode::PrtSc, "regular".to_owned()), + (LedCode::RCtrl, "regular".to_owned()), + ]), ], } } diff --git a/rog-platform/src/cpu.rs b/rog-platform/src/cpu.rs index 42a48a86..332bf6a4 100644 --- a/rog-platform/src/cpu.rs +++ b/rog-platform/src/cpu.rs @@ -267,24 +267,18 @@ mod tests { fn check_cpu() { let cpu = CPUControl::new().unwrap(); assert_eq!(cpu.get_governor().unwrap(), CPUGovernor::Powersave); - assert_eq!( - cpu.get_available_governors().unwrap(), - vec![ - CPUGovernor::Performance, - CPUGovernor::Powersave - ] - ); + assert_eq!(cpu.get_available_governors().unwrap(), vec![ + CPUGovernor::Performance, + CPUGovernor::Powersave + ]); assert_eq!(cpu.get_epp().unwrap(), CPUEPP::BalancePower); - assert_eq!( - cpu.get_available_epp().unwrap(), - vec![ - CPUEPP::Default, - CPUEPP::Performance, - CPUEPP::BalancePerformance, - CPUEPP::BalancePower, - CPUEPP::Power, - ] - ); + assert_eq!(cpu.get_available_epp().unwrap(), vec![ + CPUEPP::Default, + CPUEPP::Performance, + CPUEPP::BalancePerformance, + CPUEPP::BalancePower, + CPUEPP::Power, + ]); } } From 180d63620b9de490098567874e0daf41ab2f8856 Mon Sep 17 00:00:00 2001 From: Denis Benato Date: Wed, 8 Oct 2025 01:19:38 +0200 Subject: [PATCH 2/7] Fix multiple warnings --- asusctl/src/main.rs | 4 +- asusd/src/aura_laptop/mod.rs | 2 +- asusd/src/aura_scsi/mod.rs | 2 +- asusd/src/aura_slash/mod.rs | 2 +- rog-control-center/src/ui/setup_system.rs | 231 +++++++++--------- rog-control-center/ui/main_window.slint | 4 +- rog-control-center/ui/pages/anime.slint | 3 +- .../ui/pages/app_settings.slint | 4 +- rog-control-center/ui/pages/aura.slint | 9 +- rog-control-center/ui/pages/system.slint | 3 +- rog-control-center/ui/widgets/sidebar.slint | 3 +- 11 files changed, 140 insertions(+), 127 deletions(-) diff --git a/asusctl/src/main.rs b/asusctl/src/main.rs index 514a5d56..d2385e4b 100644 --- a/asusctl/src/main.rs +++ b/asusctl/src/main.rs @@ -1171,9 +1171,9 @@ fn print_firmware_attr(attr: &AsusArmouryProxyBlocking) -> Result<(), Box Result<(), Box> { { - if cmd.free.is_empty() || cmd.free.len() % 2 != 0 || cmd.help { + if cmd.free.is_empty() || !cmd.free.len().is_multiple_of(2) || cmd.help { const USAGE: &str = "Usage: asusctl platform panel_overdrive 1 nv_dynamic_boost 5"; - if cmd.free.len() % 2 != 0 { + if !cmd.free.len().is_multiple_of(2) { println!( "Incorrect number of args, each attribute label must be paired with a setting:" ); diff --git a/asusd/src/aura_laptop/mod.rs b/asusd/src/aura_laptop/mod.rs index a3be5068..90e55547 100644 --- a/asusd/src/aura_laptop/mod.rs +++ b/asusd/src/aura_laptop/mod.rs @@ -28,7 +28,7 @@ impl Aura { Ok(()) } - pub async fn lock_config(&self) -> MutexGuard { + pub async fn lock_config(&self) -> MutexGuard<'_, AuraConfig> { self.config.lock().await } diff --git a/asusd/src/aura_scsi/mod.rs b/asusd/src/aura_scsi/mod.rs index 182869e7..2fc45b54 100644 --- a/asusd/src/aura_scsi/mod.rs +++ b/asusd/src/aura_scsi/mod.rs @@ -20,7 +20,7 @@ impl ScsiAura { Self { device, config } } - pub async fn lock_config(&self) -> MutexGuard { + pub async fn lock_config(&self) -> MutexGuard<'_, ScsiConfig> { self.config.lock().await } diff --git a/asusd/src/aura_slash/mod.rs b/asusd/src/aura_slash/mod.rs index ef9517f0..42434003 100644 --- a/asusd/src/aura_slash/mod.rs +++ b/asusd/src/aura_slash/mod.rs @@ -27,7 +27,7 @@ impl Slash { Self { hid, usb, config } } - pub async fn lock_config(&self) -> MutexGuard { + pub async fn lock_config(&self) -> MutexGuard<'_, SlashConfig> { self.config.lock().await } diff --git a/rog-control-center/src/ui/setup_system.rs b/rog-control-center/src/ui/setup_system.rs index 52015cd7..e7d9f7f9 100644 --- a/rog-control-center/src/ui/setup_system.rs +++ b/rog-control-center/src/ui/setup_system.rs @@ -12,7 +12,7 @@ use slint::{ComponentHandle, Model, ModelRc, SharedString, VecModel}; use super::show_toast; use crate::config::Config; use crate::zbus_proxies::find_iface_async; -use crate::{set_ui_callbacks, set_ui_props_async, AttrMinMax, MainWindow, SystemPageData}; +use crate::{set_ui_callbacks, AttrMinMax, MainWindow, SystemPageData}; const MINMAX: AttrMinMax = AttrMinMax { min: 0, @@ -572,120 +572,123 @@ pub fn setup_system_page_callbacks(ui: &MainWindow, _states: Arc>) for attr in armoury_attrs { if let Ok(value) = attr.current_value().await { - let name = attr.name().await.unwrap(); - debug!("Setting up {} = {value}", <&str>::from(name)); - let platform = platform.clone(); - handle - .upgrade_in_event_loop(move |handle| match name { - FirmwareAttribute::ApuMem => {} - FirmwareAttribute::CoresPerformance => {} - FirmwareAttribute::CoresEfficiency => {} - FirmwareAttribute::PptEnabled => { - init_property!(ppt_enabled, handle, value, bool); - setup_callback!(ppt_enabled, handle, attr, bool); - let handle_copy = handle.as_weak(); - let proxy_copy = attr.clone(); - tokio::spawn(async move { - let mut x = proxy_copy.receive_current_value_changed().await; - use futures_util::StreamExt; - while let Some(e) = x.next().await { - if let Ok(out) = e.get().await { - handle_copy - .upgrade_in_event_loop(move |handle| { - handle - .global::() - .set_enable_ppt_group(out == 1); - handle - .global::() - .set_ppt_enabled(out == 1); - }) - .ok(); + if let Ok(name) = attr.name().await { + debug!("Setting up {} = {value}", <&str>::from(name)); + let platform = platform.clone(); + handle + .upgrade_in_event_loop(move |handle| match name { + FirmwareAttribute::ApuMem => {} + FirmwareAttribute::CoresPerformance => {} + FirmwareAttribute::CoresEfficiency => {} + FirmwareAttribute::PptEnabled => { + init_property!(ppt_enabled, handle, value, bool); + setup_callback!(ppt_enabled, handle, attr, bool); + let handle_copy = handle.as_weak(); + let proxy_copy = attr.clone(); + tokio::spawn(async move { + let mut x = proxy_copy.receive_current_value_changed().await; + use futures_util::StreamExt; + while let Some(e) = x.next().await { + if let Ok(out) = e.get().await { + handle_copy + .upgrade_in_event_loop(move |handle| { + handle + .global::() + .set_enable_ppt_group(out == 1); + handle + .global::() + .set_ppt_enabled(out == 1); + }) + .ok(); + } } - } - }); - handle - .global::() - .set_ppt_enabled_available(true); - handle - .global::() - .set_enable_ppt_group(value == 1); - } - FirmwareAttribute::PptPl1Spl => { - init_minmax_property!(ppt_pl1_spl, handle, attr); - setup_callback!(ppt_pl1_spl, handle, attr, i32); - setup_callback_restore_default!(ppt_pl1_spl, handle, attr); - setup_minmax_external!(ppt_pl1_spl, handle, attr, platform); - } - FirmwareAttribute::PptPl2Sppt => { - init_minmax_property!(ppt_pl2_sppt, handle, attr); - setup_callback!(ppt_pl2_sppt, handle, attr, i32); - setup_callback_restore_default!(ppt_pl2_sppt, handle, attr); - setup_minmax_external!(ppt_pl2_sppt, handle, attr, platform); - } - FirmwareAttribute::PptPl3Fppt => { - init_minmax_property!(ppt_pl3_fppt, handle, attr); - setup_callback!(ppt_pl3_fppt, handle, attr, i32); - setup_callback_restore_default!(ppt_pl3_fppt, handle, attr); - setup_minmax_external!(ppt_pl3_fppt, handle, attr, platform); - } - FirmwareAttribute::PptFppt => { - init_minmax_property!(ppt_fppt, handle, attr); - setup_callback!(ppt_fppt, handle, attr, i32); - setup_callback_restore_default!(ppt_fppt, handle, attr); - setup_minmax_external!(ppt_fppt, handle, attr, platform); - } - FirmwareAttribute::PptApuSppt => { - init_minmax_property!(ppt_apu_sppt, handle, attr); - setup_callback!(ppt_apu_sppt, handle, attr, i32); - setup_callback_restore_default!(ppt_apu_sppt, handle, attr); - setup_minmax_external!(ppt_apu_sppt, handle, attr, platform); - } - FirmwareAttribute::PptPlatformSppt => { - init_minmax_property!(ppt_platform_sppt, handle, attr); - setup_callback!(ppt_platform_sppt, handle, attr, i32); - setup_callback_restore_default!(ppt_platform_sppt, handle, attr); - setup_minmax_external!(ppt_platform_sppt, handle, attr, platform); - } - FirmwareAttribute::NvDynamicBoost => { - init_minmax_property!(nv_dynamic_boost, handle, attr); - setup_callback!(nv_dynamic_boost, handle, attr, i32); - setup_callback_restore_default!(nv_dynamic_boost, handle, attr); - setup_minmax_external!(nv_dynamic_boost, handle, attr, platform); - } - FirmwareAttribute::NvTempTarget => { - init_minmax_property!(nv_temp_target, handle, attr); - setup_callback!(nv_temp_target, handle, attr, i32); - setup_callback_restore_default!(nv_temp_target, handle, attr); - setup_minmax_external!(nv_temp_target, handle, attr, platform); - } - FirmwareAttribute::DgpuBaseTgp => {} - FirmwareAttribute::DgpuTgp => {} - FirmwareAttribute::ChargeMode => {} - FirmwareAttribute::BootSound => { - init_property!(boot_sound, handle, value, i32); - setup_callback!(boot_sound, handle, attr, i32); - setup_external!(boot_sound, i32, handle, attr, value) - } - FirmwareAttribute::McuPowersave => {} - FirmwareAttribute::PanelOverdrive => { - init_property!(panel_overdrive, handle, value, i32); - setup_callback!(panel_overdrive, handle, attr, i32); - setup_external!(panel_overdrive, i32, handle, attr, value) - } - FirmwareAttribute::PanelHdMode => {} - FirmwareAttribute::EgpuConnected => {} - FirmwareAttribute::EgpuEnable => {} - FirmwareAttribute::DgpuDisable => {} - FirmwareAttribute::GpuMuxMode => {} - FirmwareAttribute::MiniLedMode => { - init_property!(mini_led_mode, handle, value, i32); - setup_callback!(mini_led_mode, handle, attr, i32); - setup_external!(mini_led_mode, i32, handle, attr, value); - } - FirmwareAttribute::PendingReboot => {} - FirmwareAttribute::None => {} - }) - .ok(); + }); + handle + .global::() + .set_ppt_enabled_available(true); + handle + .global::() + .set_enable_ppt_group(value == 1); + } + FirmwareAttribute::PptPl1Spl => { + init_minmax_property!(ppt_pl1_spl, handle, attr); + setup_callback!(ppt_pl1_spl, handle, attr, i32); + setup_callback_restore_default!(ppt_pl1_spl, handle, attr); + setup_minmax_external!(ppt_pl1_spl, handle, attr, platform); + } + FirmwareAttribute::PptPl2Sppt => { + init_minmax_property!(ppt_pl2_sppt, handle, attr); + setup_callback!(ppt_pl2_sppt, handle, attr, i32); + setup_callback_restore_default!(ppt_pl2_sppt, handle, attr); + setup_minmax_external!(ppt_pl2_sppt, handle, attr, platform); + } + FirmwareAttribute::PptPl3Fppt => { + init_minmax_property!(ppt_pl3_fppt, handle, attr); + setup_callback!(ppt_pl3_fppt, handle, attr, i32); + setup_callback_restore_default!(ppt_pl3_fppt, handle, attr); + setup_minmax_external!(ppt_pl3_fppt, handle, attr, platform); + } + FirmwareAttribute::PptFppt => { + init_minmax_property!(ppt_fppt, handle, attr); + setup_callback!(ppt_fppt, handle, attr, i32); + setup_callback_restore_default!(ppt_fppt, handle, attr); + setup_minmax_external!(ppt_fppt, handle, attr, platform); + } + FirmwareAttribute::PptApuSppt => { + init_minmax_property!(ppt_apu_sppt, handle, attr); + setup_callback!(ppt_apu_sppt, handle, attr, i32); + setup_callback_restore_default!(ppt_apu_sppt, handle, attr); + setup_minmax_external!(ppt_apu_sppt, handle, attr, platform); + } + FirmwareAttribute::PptPlatformSppt => { + init_minmax_property!(ppt_platform_sppt, handle, attr); + setup_callback!(ppt_platform_sppt, handle, attr, i32); + setup_callback_restore_default!(ppt_platform_sppt, handle, attr); + setup_minmax_external!(ppt_platform_sppt, handle, attr, platform); + } + FirmwareAttribute::NvDynamicBoost => { + init_minmax_property!(nv_dynamic_boost, handle, attr); + setup_callback!(nv_dynamic_boost, handle, attr, i32); + setup_callback_restore_default!(nv_dynamic_boost, handle, attr); + setup_minmax_external!(nv_dynamic_boost, handle, attr, platform); + } + FirmwareAttribute::NvTempTarget => { + init_minmax_property!(nv_temp_target, handle, attr); + setup_callback!(nv_temp_target, handle, attr, i32); + setup_callback_restore_default!(nv_temp_target, handle, attr); + setup_minmax_external!(nv_temp_target, handle, attr, platform); + } + FirmwareAttribute::DgpuBaseTgp => {} + FirmwareAttribute::DgpuTgp => {} + FirmwareAttribute::ChargeMode => {} + FirmwareAttribute::BootSound => { + init_property!(boot_sound, handle, value, i32); + setup_callback!(boot_sound, handle, attr, i32); + setup_external!(boot_sound, i32, handle, attr, value) + } + FirmwareAttribute::McuPowersave => {} + FirmwareAttribute::PanelOverdrive => { + init_property!(panel_overdrive, handle, value, i32); + setup_callback!(panel_overdrive, handle, attr, i32); + setup_external!(panel_overdrive, i32, handle, attr, value) + } + FirmwareAttribute::PanelHdMode => {} + FirmwareAttribute::EgpuConnected => {} + FirmwareAttribute::EgpuEnable => {} + FirmwareAttribute::DgpuDisable => {} + FirmwareAttribute::GpuMuxMode => {} + FirmwareAttribute::MiniLedMode => { + init_property!(mini_led_mode, handle, value, i32); + setup_callback!(mini_led_mode, handle, attr, i32); + setup_external!(mini_led_mode, i32, handle, attr, value); + } + FirmwareAttribute::PendingReboot => {} + FirmwareAttribute::None => {} + }) + .ok(); + } else { + error!("Attribute with no name, skipping"); + } } } handle diff --git a/rog-control-center/ui/main_window.slint b/rog-control-center/ui/main_window.slint index acfdf437..0623c1dc 100644 --- a/rog-control-center/ui/main_window.slint +++ b/rog-control-center/ui/main_window.slint @@ -190,7 +190,9 @@ export component MainWindow inherits Window { y: 0px; width: root.width; height: root.height; - padding: 10px; + + //padding only has effect on layout elements + //padding: 10px; background: Palette.background; border-color: Palette.border; diff --git a/rog-control-center/ui/pages/anime.slint b/rog-control-center/ui/pages/anime.slint index 2ac383a9..aef04ea2 100644 --- a/rog-control-center/ui/pages/anime.slint +++ b/rog-control-center/ui/pages/anime.slint @@ -37,7 +37,8 @@ export component PageAnime inherits Rectangle { property show_builtin_advanced: false; clip: true; // TODO: slow with border-radius - padding: 8px; + //padding only has effect on layout elements + //padding: 8px; // height: parent.height - infobar.height - mainview.padding - self.padding * 2; // TODO: border-radius: 8px; VerticalLayout { diff --git a/rog-control-center/ui/pages/app_settings.slint b/rog-control-center/ui/pages/app_settings.slint index 993cbf90..d1a5e417 100644 --- a/rog-control-center/ui/pages/app_settings.slint +++ b/rog-control-center/ui/pages/app_settings.slint @@ -16,7 +16,9 @@ export component PageAppSettings inherits VerticalLayout { Rectangle { clip: true; // TODO: slow with border-radius - padding: 8px; + //padding only has effect on layout elements + //padding: 8px; + // height: parent.height - infobar.height - mainview.padding - self.padding * 2; // TODO: border-radius: 8px; mainview := VerticalLayout { diff --git a/rog-control-center/ui/pages/aura.slint b/rog-control-center/ui/pages/aura.slint index 866de1f0..71cb5281 100644 --- a/rog-control-center/ui/pages/aura.slint +++ b/rog-control-center/ui/pages/aura.slint @@ -113,7 +113,8 @@ export component PageAura inherits Rectangle { min-height: 80px; max-height: 90px; RogItem { - padding: 0px; + //padding only has effect on layout elements + //padding: 0px; VerticalBox { Text { text: @tr("Zone"); @@ -136,7 +137,8 @@ export component PageAura inherits Rectangle { } RogItem { - padding: 0px; + //padding only has effect on layout elements + //padding: 0px; VerticalBox { Text { text: @tr("Direction"); @@ -158,7 +160,8 @@ export component PageAura inherits Rectangle { } RogItem { - padding: 0px; + //padding only has effect on layout elements + //padding: 0px; VerticalBox { Text { text: @tr("Speed"); diff --git a/rog-control-center/ui/pages/system.slint b/rog-control-center/ui/pages/system.slint index e8a0b482..df913430 100644 --- a/rog-control-center/ui/pages/system.slint +++ b/rog-control-center/ui/pages/system.slint @@ -140,7 +140,8 @@ export component PageSystem inherits Rectangle { property show_fade_cover: false; property show_throttle_advanced: false; clip: true; - padding: 8px; + //padding only has effect on layout elements + //padding: 8px; ScrollView { VerticalLayout { padding: 10px; diff --git a/rog-control-center/ui/widgets/sidebar.slint b/rog-control-center/ui/widgets/sidebar.slint index b9d0323c..b3574a3f 100644 --- a/rog-control-center/ui/widgets/sidebar.slint +++ b/rog-control-center/ui/widgets/sidebar.slint @@ -4,7 +4,8 @@ import { Palette, HorizontalBox, VerticalBox } from "std-widgets.slint"; component SideBarItem inherits Rectangle { - padding: 10px; + // padding only has effect on layout elements + // padding: 10px; in property selected; in property has-focus; in-out property text <=> label.text; From 0dba22529c0fc8268ca6b9edbc77e2a909a95466 Mon Sep 17 00:00:00 2001 From: Denis Benato Date: Sat, 11 Oct 2025 20:51:57 +0200 Subject: [PATCH 3/7] feat: change limits dynamically --- asusd/src/asus_armoury.rs | 76 +++++++++++++++++++----- asusd/src/ctrl_platform.rs | 54 ++++++++++++++--- asusd/src/daemon.rs | 14 +++-- rog-control-center/ui/pages/system.slint | 18 +++--- rog-platform/src/asus_armoury.rs | 16 +++++ 5 files changed, 143 insertions(+), 35 deletions(-) diff --git a/asusd/src/asus_armoury.rs b/asusd/src/asus_armoury.rs index bb78130e..2e03a651 100644 --- a/asusd/src/asus_armoury.rs +++ b/asusd/src/asus_armoury.rs @@ -55,6 +55,25 @@ impl AsusArmouryAttribute { String::from(self.attr.name()) } + fn resolve_i32_value(refreshed: Option, cached: &AttrValue) -> i32 { + refreshed + .or_else(|| match cached { + AttrValue::Integer(i) => Some(*i), + _ => None, + }) + .unwrap_or(-1) + } + + pub async fn emit_limits(&self, connection: &Connection) -> Result<(), RogError> { + let path = dbus_path_for_attr(self.attr.name()); + let signal = SignalEmitter::new(connection, path)?; + self.min_value_changed(&signal).await?; + self.max_value_changed(&signal).await?; + self.scalar_increment_changed(&signal).await?; + self.current_value_changed(&signal).await?; + Ok(()) + } + pub async fn move_to_zbus(self, connection: &Connection) -> Result<(), RogError> { let path = dbus_path_for_attr(self.attr.name()); connection @@ -117,6 +136,35 @@ impl AsusArmouryAttribute { } } +#[derive(Clone, Default)] +pub struct ArmouryAttributeRegistry { + attrs: Vec, +} + +impl ArmouryAttributeRegistry { + pub fn push(&mut self, attr: AsusArmouryAttribute) { + self.attrs.push(attr); + } + + pub async fn emit_limits(&self, connection: &Connection) -> Result<(), RogError> { + let mut last_err: Option = None; + for attr in &self.attrs { + if let Err(e) = attr.emit_limits(connection).await { + error!( + "Failed to emit updated limits for attribute '{}': {e:?}", + attr.attribute_name() + ); + last_err = Some(e); + } + } + if let Some(err) = last_err { + Err(err) + } else { + Ok(()) + } + } +} + impl crate::Reloadable for AsusArmouryAttribute { async fn reload(&mut self) -> Result<(), RogError> { info!("Reloading {}", self.attr.name()); @@ -256,26 +304,20 @@ impl AsusArmouryAttribute { #[zbus(property)] async fn min_value(&self) -> i32 { - match self.attr.min_value() { - AttrValue::Integer(i) => *i, - _ => -1, - } + Self::resolve_i32_value(self.attr.refresh_min_value(), self.attr.min_value()) } #[zbus(property)] async fn max_value(&self) -> i32 { - match self.attr.max_value() { - AttrValue::Integer(i) => *i, - _ => -1, - } + Self::resolve_i32_value(self.attr.refresh_max_value(), self.attr.max_value()) } #[zbus(property)] async fn scalar_increment(&self) -> i32 { - match self.attr.scalar_increment() { - AttrValue::Integer(i) => *i, - _ => -1, - } + Self::resolve_i32_value( + self.attr.refresh_scalar_increment(), + self.attr.scalar_increment(), + ) } #[zbus(property)] @@ -393,7 +435,8 @@ pub async fn start_attributes_zbus( power: AsusPower, attributes: FirmwareAttributes, config: Arc>, -) -> Result<(), RogError> { +) -> Result { + let mut registry = ArmouryAttributeRegistry::default(); for attr in attributes.attributes() { let mut attr = AsusArmouryAttribute::new( attr.clone(), @@ -402,6 +445,8 @@ pub async fn start_attributes_zbus( config.clone(), ); + let registry_attr = attr.clone(); + if let Err(e) = attr.reload().await { error!( "Skipping attribute '{}' due to reload error: {e:?}", @@ -430,9 +475,12 @@ pub async fn start_attributes_zbus( if let Err(e) = attr.move_to_zbus(conn).await { error!("Failed to register attribute '{attr_name}' on zbus: {e:?}"); + continue; } + + registry.push(registry_attr); } - Ok(()) + Ok(registry) } pub async fn set_config_or_default( diff --git a/asusd/src/ctrl_platform.rs b/asusd/src/ctrl_platform.rs index f3dc369c..b5b896ee 100644 --- a/asusd/src/ctrl_platform.rs +++ b/asusd/src/ctrl_platform.rs @@ -13,7 +13,7 @@ use zbus::fdo::Error as FdoErr; use zbus::object_server::SignalEmitter; use zbus::{interface, Connection}; -use crate::asus_armoury::set_config_or_default; +use crate::asus_armoury::{set_config_or_default, ArmouryAttributeRegistry}; use crate::config::Config; use crate::error::RogError; use crate::{task_watch_item, CtrlTask, ReloadAndNotify}; @@ -46,6 +46,8 @@ pub struct CtrlPlatform { attributes: FirmwareAttributes, cpu_control: Option, config: Arc>, + connection: Connection, + armoury_registry: ArmouryAttributeRegistry, } impl CtrlPlatform { @@ -56,6 +58,8 @@ impl CtrlPlatform { config: Arc>, config_path: &Path, signal_context: SignalEmitter<'static>, + connection: Connection, + armoury_registry: ArmouryAttributeRegistry, ) -> Result { let config1 = config.clone(); let config_path = config_path.to_owned(); @@ -68,6 +72,8 @@ impl CtrlPlatform { cpu_control: CPUControl::new() .map_err(|e| error!("Couldn't get CPU control sysfs: {e}")) .ok(), + connection, + armoury_registry, }; let mut inotify_self = ret_self.clone(); @@ -729,6 +735,31 @@ impl CtrlTask for CtrlPlatform { } if !sleeping { platform1.run_ac_or_bat_cmd(power_plugged > 0).await; + if let Ok(profile) = + platform1.platform.get_platform_profile().map(|p| p.into()) + { + let attrs = FirmwareAttributes::new(); + { + let mut cfg = platform1.config.lock().await; + set_config_or_default( + &attrs, + &mut *cfg, + power_plugged > 0, + profile, + ) + .await; + } + if let Err(e) = platform1 + .armoury_registry + .emit_limits(&platform1.connection) + .await + { + error!( + "Failed to emit armoury updates after power change: \ + {e:?}" + ); + } + } } platform1.config.lock().await.last_power_plugged = power_plugged; } @@ -789,13 +820,17 @@ impl CtrlTask for CtrlPlatform { { // TODO: manage this better, shouldn't need to create every time let attrs = FirmwareAttributes::new(); - set_config_or_default( - &attrs, - &mut *platform3.config.lock().await, - power_plugged, - profile, - ) - .await; + { + let mut cfg = platform3.config.lock().await; + set_config_or_default(&attrs, &mut *cfg, power_plugged, profile).await; + } + if let Err(e) = platform3 + .armoury_registry + .emit_limits(&platform3.connection) + .await + { + error!("Failed to emit armoury updates after AC/DC toggle: {e:?}"); + } platform3 .enable_ppt_group_changed(&signal_ctxt_copy) .await @@ -852,6 +887,9 @@ impl CtrlTask for CtrlPlatform { profile, ) .await; + if let Err(e) = ctrl.armoury_registry.emit_limits(&ctrl.connection).await { + error!("Failed to emit armoury updates after profile change: {e:?}"); + } } } } diff --git a/asusd/src/daemon.rs b/asusd/src/daemon.rs index 10b8f371..455b7c89 100644 --- a/asusd/src/daemon.rs +++ b/asusd/src/daemon.rs @@ -3,7 +3,7 @@ use std::error::Error; use std::sync::Arc; use ::zbus::Connection; -use asusd::asus_armoury::start_attributes_zbus; +use asusd::asus_armoury::{start_attributes_zbus, ArmouryAttributeRegistry}; use asusd::aura_manager::DeviceManager; use asusd::config::Config; use asusd::ctrl_backlight::CtrlBacklight; @@ -74,7 +74,7 @@ async fn start_daemon() -> Result<(), Box> { let platform = RogPlatform::new()?; // TODO: maybe needs async mutex? let power = AsusPower::new()?; // TODO: maybe needs async mutex? let attributes = FirmwareAttributes::new(); - if let Err(e) = start_attributes_zbus( + let armoury_registry = match start_attributes_zbus( &server, platform.clone(), power.clone(), @@ -83,8 +83,12 @@ async fn start_daemon() -> Result<(), Box> { ) .await { - error!("Failed to initialize firmware attributes over zbus: {e:?}"); - } + Ok(registry) => registry, + Err(e) => { + error!("Failed to initialize firmware attributes over zbus: {e:?}"); + ArmouryAttributeRegistry::default() + } + }; match CtrlFanCurveZbus::new() { Ok(ctrl) => { @@ -113,6 +117,8 @@ async fn start_daemon() -> Result<(), Box> { config.clone(), &cfg_path, CtrlPlatform::signal_context(&server)?, + server.clone(), + armoury_registry, ) { Ok(ctrl) => { let sig_ctx = CtrlPlatform::signal_context(&server)?; diff --git a/rog-control-center/ui/pages/system.slint b/rog-control-center/ui/pages/system.slint index df913430..328c2735 100644 --- a/rog-control-center/ui/pages/system.slint +++ b/rog-control-center/ui/pages/system.slint @@ -302,7 +302,7 @@ export component PageSystem inherits Rectangle { } } - if SystemPageData.ppt_pl1_spl.current != -1 || SystemPageData.ppt_pl2_sppt.current != -1 || SystemPageData.ppt_pl3_fppt.current != -1 || SystemPageData.ppt_fppt.current != -1 || SystemPageData.ppt_apu_sppt.current != -1 || SystemPageData.nv_temp_target.current != -1 || SystemPageData.nv_dynamic_boost.current != -1: HorizontalLayout { + if (SystemPageData.ppt_pl1_spl.max > 0 && SystemPageData.ppt_pl1_spl.current != -1) || (SystemPageData.ppt_pl2_sppt.max > 0 && SystemPageData.ppt_pl2_sppt.current != -1) || (SystemPageData.ppt_pl3_fppt.max > 0 && SystemPageData.ppt_pl3_fppt.current != -1) || (SystemPageData.ppt_fppt.max > 0 && SystemPageData.ppt_fppt.current != -1) || (SystemPageData.ppt_apu_sppt.max > 0 && SystemPageData.ppt_apu_sppt.current != -1) || (SystemPageData.nv_temp_target.max > 0 && SystemPageData.nv_temp_target.current != -1) || (SystemPageData.nv_dynamic_boost.max > 0 && SystemPageData.nv_dynamic_boost.current != -1): HorizontalLayout { padding-right: 10px; padding-left: 10px; alignment: LayoutAlignment.space-between; @@ -331,7 +331,7 @@ export component PageSystem inherits Rectangle { } } - if SystemPageData.ppt_pl1_spl.current != -1: SystemSlider { + if SystemPageData.ppt_pl1_spl.max > 0 && SystemPageData.ppt_pl1_spl.current != -1: SystemSlider { text: @tr("ppt_pl1_spl" => "CPU Sustained Power Limit"); title: @tr("ppt_pl1_spl" => "CPU Sustained Power Limit"); help_text: @tr("ppt_pl1_spl_help" => "Long-term CPU power limit that affects sustained workload performance. Higher values may increase heat and power consumption."); @@ -349,7 +349,7 @@ export component PageSystem inherits Rectangle { } } - if SystemPageData.ppt_pl2_sppt.current != -1: SystemSlider { + if SystemPageData.ppt_pl2_sppt.max > 0 && SystemPageData.ppt_pl2_sppt.current != -1: SystemSlider { text: @tr("ppt_pl2_sppt" => "CPU Turbo Power Limit"); title: @tr("ppt_pl2_sppt" => "CPU Turbo Power Limit"); help_text: @tr("ppt_pl2_sppt_help" => "Short-term CPU power limit for boost periods. Controls maximum power during brief high-performance bursts."); @@ -367,7 +367,7 @@ export component PageSystem inherits Rectangle { } } - if SystemPageData.ppt_pl3_fppt.current != -1: SystemSlider { + if SystemPageData.ppt_pl3_fppt.max > 0 && SystemPageData.ppt_pl3_fppt.current != -1: SystemSlider { text: @tr("ppt_pl3_fppt" => "CPU Fast Burst Power Limit"); title: @tr("ppt_pl3_fppt" => "CPU Fast Burst Power Limit"); help_text: @tr("ppt_pl3_fppt_help" => "Ultra-short duration power limit for instantaneous CPU bursts. Affects responsiveness during sudden workload spikes."); @@ -384,7 +384,7 @@ export component PageSystem inherits Rectangle { SystemPageData.cb_ppt_pl3_fppt(Math.round(value)); } } - if SystemPageData.ppt_fppt.current != -1: SystemSlider { + if SystemPageData.ppt_fppt.max > 0 && SystemPageData.ppt_fppt.current != -1: SystemSlider { text: @tr("ppt_fppt" => "Fast Package Power Limit"); title: @tr("ppt_fppt" => "Fast Package Power Limit"); help_text: @tr("ppt_fppt_help" => "Ultra-short duration power limit for system package. Controls maximum power during millisecond-scale load spikes."); @@ -402,7 +402,7 @@ export component PageSystem inherits Rectangle { } } - if SystemPageData.ppt_apu_sppt.current != -1: SystemSlider { + if SystemPageData.ppt_apu_sppt.max > 0 && SystemPageData.ppt_apu_sppt.current != -1: SystemSlider { text: @tr("ppt_apu_sppt" => "APU Sustained Power Limit"); title: @tr("ppt_apu_sppt" => "APU Sustained Power Limit"); help_text: @tr("ppt_apu_sppt_help" => "Long-term power limit for integrated graphics and CPU combined. Affects sustained performance of APU-based workloads."); @@ -420,7 +420,7 @@ export component PageSystem inherits Rectangle { } } - if SystemPageData.ppt_platform_sppt.current != -1: SystemSlider { + if SystemPageData.ppt_platform_sppt.max > 0 && SystemPageData.ppt_platform_sppt.current != -1: SystemSlider { text: @tr("ppt_platform_sppt" => "Platform Sustained Power Limit"); title: @tr("ppt_platform_sppt" => "Platform Sustained Power Limit"); help_text: @tr("ppt_platform_sppt_help" => "Overall system power limit for sustained operations. Controls total platform power consumption over extended periods."); @@ -438,7 +438,7 @@ export component PageSystem inherits Rectangle { } } - if SystemPageData.nv_dynamic_boost.current != -1: SystemSlider { + if SystemPageData.nv_dynamic_boost.max > 0 && SystemPageData.nv_dynamic_boost.current != -1: SystemSlider { text: @tr("nv_dynamic_boost" => "GPU Power Boost"); title: @tr("nv_dynamic_boost" => "GPU Power Boost"); help_text: @tr("nv_dynamic_boost_help" => "Additional power allocation for GPU dynamic boost. Higher values increase GPU performance but generate more heat."); @@ -456,7 +456,7 @@ export component PageSystem inherits Rectangle { } } - if SystemPageData.nv_temp_target.current != -1: SystemSlider { + if SystemPageData.nv_temp_target.max > 0 && SystemPageData.nv_temp_target.current != -1: SystemSlider { text: @tr("nv_temp_target" => "GPU Temperature Limit"); title: @tr("nv_temp_target" => "GPU Temperature Limit"); help_text: @tr("nv_temp_target_help" => "Maximum GPU temperature threshold in Celsius. GPU will throttle to maintain temperature below this limit."); diff --git a/rog-platform/src/asus_armoury.rs b/rog-platform/src/asus_armoury.rs index 455f3158..b0dd2834 100644 --- a/rog-platform/src/asus_armoury.rs +++ b/rog-platform/src/asus_armoury.rs @@ -124,6 +124,22 @@ impl Attribute { &self.scalar_increment } + fn read_attr_i32(&self, name: &str) -> Option { + read_i32(&self.base_path.join(name)).ok() + } + + pub fn refresh_min_value(&self) -> Option { + self.read_attr_i32("min_value") + } + + pub fn refresh_max_value(&self) -> Option { + self.read_attr_i32("max_value") + } + + pub fn refresh_scalar_increment(&self) -> Option { + self.read_attr_i32("scalar_increment") + } + /// Read all the immutable values to struct data. These should *never* /// change, if they do then it is possibly a driver issue - although this is /// subject to `firmware_attributes` class changes in kernel. From c3b5de843f12fec5677cfd59f6c9a7408ccb3054 Mon Sep 17 00:00:00 2001 From: HiFiPhile Date: Sat, 6 Sep 2025 15:13:03 +0200 Subject: [PATCH 4/7] Add TX Air rule --- data/asusd.rules | 1 + 1 file changed, 1 insertion(+) diff --git a/data/asusd.rules b/data/asusd.rules index 78a438ae..e0f136f4 100644 --- a/data/asusd.rules +++ b/data/asusd.rules @@ -9,6 +9,7 @@ ENV{DMI_FAMILY}=="*Strix*", GOTO="asusd_start" ENV{DMI_FAMILY}=="*Vivo*ook*", GOTO="asusd_start" ENV{DMI_FAMILY}=="*Zenbook*", GOTO="asusd_start" ENV{DMI_FAMILY}=="*ProArt*", GOTO="asusd_start" +ENV{DMI_FAMILY}=="*TX Air*", GOTO="asusd_start" ENV{DMI_FAMILY}=="*TX Gaming*", GOTO="asusd_start" # No match so GOTO="asusd_end" From 1c1daaa6d2d59b77f1af91211d822d1b2cde773b Mon Sep 17 00:00:00 2001 From: Denis Benato Date: Sun, 12 Oct 2025 19:47:26 +0200 Subject: [PATCH 5/7] chore: reimplement default for FanCurveCPU --- rog-profiles/src/lib.rs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/rog-profiles/src/lib.rs b/rog-profiles/src/lib.rs index 1000923c..51e91d88 100644 --- a/rog-profiles/src/lib.rs +++ b/rog-profiles/src/lib.rs @@ -37,8 +37,9 @@ pub fn find_fan_curve_node() -> Result { derive(Type, Value, OwnedValue), zvariant(signature = "s") )] -#[derive(Deserialize, Serialize, Debug, Hash, PartialEq, Eq, Clone, Copy)] +#[derive(Default, Deserialize, Serialize, Debug, Hash, PartialEq, Eq, Clone, Copy)] pub enum FanCurvePU { + #[default] CPU = 0, GPU = 1, MID = 2, @@ -100,12 +101,6 @@ impl std::str::FromStr for FanCurvePU { } } -impl Default for FanCurvePU { - fn default() -> Self { - Self::CPU - } -} - /// Main purpose of `FanCurves` is to enable restoring state on system boot #[cfg_attr(feature = "dbus", derive(Type))] #[derive(Deserialize, Serialize, Debug, Default)] From b0e1b21e4bd9948d1872a6aff457e3984590a2b5 Mon Sep 17 00:00:00 2001 From: Denis Benato Date: Sun, 12 Oct 2025 22:34:20 +0200 Subject: [PATCH 6/7] chore: cargo clippy fix --- asusd/src/asus_armoury.rs | 2 +- asusd/src/ctrl_platform.rs | 4 ++-- rog-anime/src/image.rs | 6 +++--- simulators/src/simulator.rs | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/asusd/src/asus_armoury.rs b/asusd/src/asus_armoury.rs index 2e03a651..cc74cd32 100644 --- a/asusd/src/asus_armoury.rs +++ b/asusd/src/asus_armoury.rs @@ -57,7 +57,7 @@ impl AsusArmouryAttribute { fn resolve_i32_value(refreshed: Option, cached: &AttrValue) -> i32 { refreshed - .or_else(|| match cached { + .or(match cached { AttrValue::Integer(i) => Some(*i), _ => None, }) diff --git a/asusd/src/ctrl_platform.rs b/asusd/src/ctrl_platform.rs index b5b896ee..65e57c5f 100644 --- a/asusd/src/ctrl_platform.rs +++ b/asusd/src/ctrl_platform.rs @@ -743,7 +743,7 @@ impl CtrlTask for CtrlPlatform { let mut cfg = platform1.config.lock().await; set_config_or_default( &attrs, - &mut *cfg, + &mut cfg, power_plugged > 0, profile, ) @@ -822,7 +822,7 @@ impl CtrlTask for CtrlPlatform { let attrs = FirmwareAttributes::new(); { let mut cfg = platform3.config.lock().await; - set_config_or_default(&attrs, &mut *cfg, power_plugged, profile).await; + set_config_or_default(&attrs, &mut cfg, power_plugged, profile).await; } if let Err(e) = platform3 .armoury_registry diff --git a/rog-anime/src/image.rs b/rog-anime/src/image.rs index 197d2378..fee51da7 100644 --- a/rog-anime/src/image.rs +++ b/rog-anime/src/image.rs @@ -169,7 +169,7 @@ impl AnimeImage { // first 5 rows for GA401 are always at X = 0 return 0; } - (y + 1) / 2 - 3 + y.div_ceil(2) - 3 } AnimeType::GU604 => { // first 9 rows start at zero @@ -185,7 +185,7 @@ impl AnimeImage { return 0; } // and then their offset grows by one every two rows - (y + 1) / 2 - 5 + y.div_ceil(2) - 5 } } } @@ -213,7 +213,7 @@ impl AnimeImage { // First 5 rows for GA401 are always 33 physical LEDs long return 33; } - 36 - (y + 1) / 2 + 36 - y.div_ceil(2) } AnimeType::GU604 => { if y <= 9 { diff --git a/simulators/src/simulator.rs b/simulators/src/simulator.rs index c719ffd9..cbeacf09 100644 --- a/simulators/src/simulator.rs +++ b/simulators/src/simulator.rs @@ -158,7 +158,7 @@ fn main() -> Result<(), Box> { canvas.set_draw_color(Color::RGB(*b, *b, *b)); let x: i32 = w + x_count as i32 * w - - if (y_count + y_offset as usize) % 2 != 0 { + - if !(y_count + y_offset as usize).is_multiple_of(2) { 0 } else { w / 2 From d11fc20babdd2416567681073a83a366e677369a Mon Sep 17 00:00:00 2001 From: Denis Benato Date: Mon, 13 Oct 2025 03:46:50 +0200 Subject: [PATCH 7/7] feat: apply the proper configuration depending on the plug status --- asusd/src/asus_armoury.rs | 134 +++++++++++++++++++++++++++++++------- asusd/src/config.rs | 22 ++++++- 2 files changed, 130 insertions(+), 26 deletions(-) diff --git a/asusd/src/asus_armoury.rs b/asusd/src/asus_armoury.rs index cc74cd32..776bcd42 100644 --- a/asusd/src/asus_armoury.rs +++ b/asusd/src/asus_armoury.rs @@ -179,25 +179,31 @@ impl crate::Reloadable for AsusArmouryAttribute { error!("Could not get power status: {e:?}"); e }) - .unwrap_or_default(); - let config = if power_plugged == 1 { - &self.config.lock().await.ac_profile_tunings - } else { - &self.config.lock().await.dc_profile_tunings + .unwrap_or_default() + == 1; + + let apply_value = { + let config = self.config.lock().await; + config + .select_tunings_ref(power_plugged, profile) + .and_then(|tuning| { + if tuning.enabled { + tuning.group.get(&self.name()).copied() + } else { + None + } + }) }; - if let Some(tuning) = config.get(&profile) { - if tuning.enabled { - if let Some(tune) = tuning.group.get(&self.name()) { - self.attr - .set_current_value(&AttrValue::Integer(*tune)) - .map_err(|e| { - error!("Could not set {} value: {e:?}", self.attr.name()); - self.attr.base_path_exists(); - e - })?; - info!("Set {} to {:?}", self.attr.name(), tune); - } - } + + if let Some(tune) = apply_value { + self.attr + .set_current_value(&AttrValue::Integer(tune)) + .map_err(|e| { + error!("Could not set {} value: {e:?}", self.attr.name()); + self.attr.base_path_exists(); + e + })?; + info!("Set {} to {:?}", self.attr.name(), tune); } } else { // Handle non-PPT attributes (boolean and other settings) @@ -339,12 +345,15 @@ impl AsusArmouryAttribute { error!("Could not get power status: {e:?}"); e }) - .unwrap_or_default(); - let mut config = self.config.lock().await; - let tuning = config.select_tunings(power_plugged == 1, profile); - if let Some(tune) = tuning.group.get(&self.name()) { - return Ok(*tune); - } else if let AttrValue::Integer(i) = self.attr.default_value() { + .unwrap_or_default() + == 1; + let config = self.config.lock().await; + if let Some(tuning) = config.select_tunings_ref(power_plugged, profile) { + if let Some(tune) = tuning.group.get(&self.name()) { + return Ok(*tune); + } + } + if let AttrValue::Integer(i) = self.attr.default_value() { return Ok(*i); } return Err(fdo::Error::Failed( @@ -360,6 +369,83 @@ impl AsusArmouryAttribute { )) } + async fn stored_value_for_power(&self, on_ac: bool) -> fdo::Result { + if !self.name().is_ppt() { + return Err(fdo::Error::NotSupported( + "Stored values are only available for PPT attributes".to_string(), + )); + } + + let profile: PlatformProfile = self.platform.get_platform_profile()?.into(); + let config = self.config.lock().await; + if let Some(tuning) = config.select_tunings_ref(on_ac, profile) { + if let Some(tune) = tuning.group.get(&self.name()) { + return Ok(*tune); + } + } + + if let AttrValue::Integer(i) = self.attr.default_value() { + return Ok(*i); + } + Err(fdo::Error::Failed( + "Could not read stored value".to_string(), + )) + } + + async fn set_value_for_power(&mut self, on_ac: bool, value: i32) -> fdo::Result<()> { + if !self.name().is_ppt() { + return Err(fdo::Error::NotSupported( + "Setting stored values is only supported for PPT attributes".to_string(), + )); + } + + let profile: PlatformProfile = self.platform.get_platform_profile()?.into(); + let apply_now; + + { + let mut config = self.config.lock().await; + let tuning = config.select_tunings(on_ac, profile); + + if let Some(tune) = tuning.group.get_mut(&self.name()) { + *tune = value; + } else { + tuning.group.insert(self.name(), value); + debug!( + "Store {} value for {} power = {}", + self.attr.name(), + if on_ac { "AC" } else { "DC" }, + value + ); + } + + apply_now = tuning.enabled; + config.write(); + } + + if apply_now { + let power_plugged = self + .power + .get_online() + .map_err(|e| { + error!("Could not get power status: {e:?}"); + e + }) + .unwrap_or_default() + != 0; + + if power_plugged == on_ac { + self.attr + .set_current_value(&AttrValue::Integer(value)) + .map_err(|e| { + error!("Could not set value: {e:?}"); + e + })?; + } + } + + Ok(()) + } + #[zbus(property)] async fn set_current_value(&mut self, value: i32) -> fdo::Result<()> { if self.name().is_ppt() { diff --git a/asusd/src/config.rs b/asusd/src/config.rs index db7f9cf2..9515cfc4 100644 --- a/asusd/src/config.rs +++ b/asusd/src/config.rs @@ -67,6 +67,19 @@ impl Config { }; config.entry(profile).or_insert_with(Tuning::default) } + + pub fn select_tunings_ref( + &self, + power_plugged: bool, + profile: PlatformProfile, + ) -> Option<&Tuning> { + let config = if power_plugged { + &self.ac_profile_tunings + } else { + &self.dc_profile_tunings + }; + config.get(&profile) + } } impl Default for Config { @@ -146,7 +159,7 @@ pub struct Config611 { impl From for Config { fn from(c: Config611) -> Self { - Self { + let mut config = Self { // Restore the base charge limit charge_control_end_threshold: c.charge_control_end_threshold, base_charge_control_end_threshold: c.charge_control_end_threshold, @@ -168,7 +181,12 @@ impl From for Config { armoury_settings: HashMap::default(), screenpad_gamma: None, screenpad_sync_primary: Default::default(), - } + }; + + config.ac_profile_tunings = c.ac_profile_tunings; + config.dc_profile_tunings = c.dc_profile_tunings; + config.armoury_settings = c.armoury_settings; + config } }