Compare commits

...

5 Commits

Author SHA1 Message Date
Denis Benato
7edb77b41f fix: make the linter happy again 2026-01-18 23:43:22 +01:00
Denis Benato
737ffa522c chore: update CHANGELOG.md 2026-01-18 23:41:26 +01:00
Denis Benato
0311cfb1f9 fix: improve handling of different attribute types 2026-01-18 23:38:45 +01:00
Denis Benato
b0ee27fb74 Merge branch 'rogcc_toast_look_update' into 'devel'
rog-control-center toast message update

See merge request asus-linux/asusctl!248
2026-01-18 22:15:02 +00:00
Mykola Shevchenko
d4eca0c93e feat: improve toast message for rogcc 2026-01-18 22:15:02 +00:00
5 changed files with 200 additions and 179 deletions

View File

@@ -1,5 +1,11 @@
# Changelog # Changelog
## [6.3.2]
### Changes
- Improve the notification area, @shevchenko0013 strikes again!
- Improve firmware attributes handling
## [6.3.1] ## [6.3.1]
### Changes ### Changes

View File

@@ -2,7 +2,9 @@ use std::sync::Arc;
use config_traits::StdConfig; use config_traits::StdConfig;
use log::{debug, error, info, warn}; use log::{debug, error, info, warn};
use rog_platform::asus_armoury::{AttrValue, Attribute, FirmwareAttribute, FirmwareAttributes}; use rog_platform::asus_armoury::{
AttrValue, Attribute, FirmwareAttribute, FirmwareAttributeType, FirmwareAttributes,
};
use rog_platform::platform::{PlatformProfile, RogPlatform}; use rog_platform::platform::{PlatformProfile, RogPlatform};
use rog_platform::power::AsusPower; use rog_platform::power::AsusPower;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@@ -168,82 +170,64 @@ impl ArmouryAttributeRegistry {
impl crate::Reloadable for AsusArmouryAttribute { impl crate::Reloadable for AsusArmouryAttribute {
async fn reload(&mut self) -> Result<(), RogError> { async fn reload(&mut self) -> Result<(), RogError> {
info!("Reloading {}", self.attr.name()); info!("Reloading {}", self.attr.name());
let name: FirmwareAttribute = self.attr.name().into(); let attribute: FirmwareAttribute = self.attr.name().into();
let name = self.attr.name();
// Treat dGPU attributes the same as PPT attributes for power-profile let config = self.config.lock().await;
// behaviour so they follow AC/DC tuning groups. let apply_value = match attribute.property_type() {
if name.is_ppt() || name.is_dgpu() { FirmwareAttributeType::Ppt => {
let profile: PlatformProfile = self.platform.get_platform_profile()?.into(); let profile: PlatformProfile = self.platform.get_platform_profile()?.into();
let power_plugged = self let power_plugged = self
.power .power
.get_online() .get_online()
.map_err(|e| { .map_err(|e| {
error!("Could not get power status: {e:?}"); error!("Could not get power status: {e:?}");
e e
})
.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
}
}) })
}; .unwrap_or_default()
== 1;
if let Some(tune) = apply_value { let apply_value = {
self.attr config.select_tunings_ref(power_plugged, profile).and_then(
.set_current_value(&AttrValue::Integer(tune)) |tuning| match tuning.enabled {
.map_err(|e| { true => tuning.group.get(&self.name()).copied(),
error!("Could not set {} value: {e:?}", self.attr.name()); false => None,
self.attr.base_path_exists(); },
e )
})?; };
info!(
"Restored PPT armoury setting {} to {:?}", apply_value.map_or(AttrValue::None, AttrValue::Integer)
self.attr.name(),
tune
);
} else {
info!("Ignored restoring PPT armoury setting {} as tuning group is disabled or no saved value", self.attr.name());
} }
} else { FirmwareAttributeType::Gpu => {
// Handle non-PPT attributes (boolean and other settings) info!("Reload called on GPU attribute {name}: doing nothing");
if let Some(saved_value) = self.config.lock().await.armoury_settings.get(&name) { AttrValue::None
self.attr
.set_current_value(&AttrValue::Integer(*saved_value))
.map_err(|e| {
error!(
"Error restoring armoury setting {}: {e:?}",
self.attr.name()
);
self.attr.base_path_exists();
e
})?;
info!(
"Restored armoury setting {} to {:?}",
self.attr.name(),
saved_value
);
} else {
info!(
"No saved armoury setting for {}: skipping restore",
self.attr.name()
);
} }
} _ => {
info!("Reload called on firmware attribute {name}");
match config.armoury_settings.get(&attribute) {
Some(saved_value) => AttrValue::Integer(*saved_value),
None => AttrValue::None,
}
}
};
self.attr.set_current_value(&apply_value).map_err(|e| {
error!("Could not set {} value: {e:?}", self.attr.name());
self.attr.base_path_exists();
e
})?;
info!(
"Restored asus-armoury setting {} to {:?}",
self.attr.name(),
apply_value
);
Ok(()) Ok(())
} }
} }
/// If return is `-1` on a property then there is avilable value for that /// If return is `-1` on a property then there is available value for that
/// property /// property
#[interface(name = "xyz.ljones.AsusArmoury")] #[interface(name = "xyz.ljones.AsusArmoury")]
impl AsusArmouryAttribute { impl AsusArmouryAttribute {
@@ -293,7 +277,7 @@ impl AsusArmouryAttribute {
async fn restore_default(&self) -> fdo::Result<()> { async fn restore_default(&self) -> fdo::Result<()> {
self.attr.restore_default()?; self.attr.restore_default()?;
if self.name().is_ppt() || self.name().is_dgpu() { if self.name().property_type() == FirmwareAttributeType::Ppt {
let profile: PlatformProfile = self.platform.get_platform_profile()?.into(); let profile: PlatformProfile = self.platform.get_platform_profile()?.into();
let power_plugged = self let power_plugged = self
.power .power
@@ -352,7 +336,7 @@ impl AsusArmouryAttribute {
#[zbus(property)] #[zbus(property)]
async fn current_value(&self) -> fdo::Result<i32> { async fn current_value(&self) -> fdo::Result<i32> {
if self.name().is_ppt() || self.name().is_dgpu() { if self.name().property_type() == FirmwareAttributeType::Ppt {
let profile: PlatformProfile = self.platform.get_platform_profile()?.into(); let profile: PlatformProfile = self.platform.get_platform_profile()?.into();
let power_plugged = self let power_plugged = self
.power .power
@@ -387,66 +371,62 @@ impl AsusArmouryAttribute {
#[zbus(property)] #[zbus(property)]
async fn set_current_value(&mut self, value: i32) -> fdo::Result<()> { async fn set_current_value(&mut self, value: i32) -> fdo::Result<()> {
if self.name().is_ppt() || self.name().is_dgpu() { let name = self.attr.name();
let profile: PlatformProfile = self.platform.get_platform_profile()?.into(); let apply_value = match self.name().property_type() {
let power_plugged = self FirmwareAttributeType::Ppt => {
.power let profile: PlatformProfile = self.platform.get_platform_profile()?.into();
.get_online() let power_plugged = self
.map_err(|e| { .power
error!("Could not get power status: {e:?}"); .get_online()
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_mut(&self.name()) {
*tune = value;
} else {
tuning.group.insert(self.name(), value);
debug!("Store tuning config for {} = {:?}", self.attr.name(), value);
}
if tuning.enabled {
self.attr
.set_current_value(&AttrValue::Integer(value))
.map_err(|e| { .map_err(|e| {
error!( error!("Could not get power status: {e:?}");
"Could not set value to PPT property {}: {e:?}",
self.attr.name()
);
e e
})?; })
} else { .unwrap_or_default();
warn!(
"Tuning group is disabled: skipping setting value to PPT property {}",
self.attr.name()
);
}
} else {
self.attr
.set_current_value(&AttrValue::Integer(value))
.map_err(|e| {
error!(
"Could not set value {value} to attribute {}: {e:?}",
self.attr.name()
);
e
})?;
let mut settings = self.config.lock().await; let mut config = self.config.lock().await;
settings let tuning = config.select_tunings(power_plugged == 1, profile);
.armoury_settings
.entry(self.name()) if let Some(tune) = tuning.group.get_mut(&self.name()) {
.and_modify(|setting| { *tune = value;
debug!("Set config for {} = {value}", self.attr.name()); } else {
*setting = value; tuning.group.insert(self.name(), value);
}) debug!("Store tuning config for {name} = {:?}", value);
.or_insert_with(|| { }
debug!("Adding config for {} = {value}", self.attr.name());
value match tuning.enabled {
}); true => {
} debug!("Tuning is enabled: setting value to PPT property {name} = {value}");
AttrValue::Integer(value)
}
false => {
warn!("Tuning is disabled: skipping setting value to PPT property {name}");
AttrValue::None
}
}
}
_ => {
let mut settings = self.config.lock().await;
settings
.armoury_settings
.entry(self.name())
.and_modify(|setting| {
debug!("Set config for {name} = {value}");
*setting = value;
})
.or_insert_with(|| {
debug!("Adding config for {name} = {value}");
value
});
AttrValue::Integer(value)
}
};
self.attr.set_current_value(&apply_value).map_err(|e| {
error!("Could not set value {value} to attribute {name}: {e:?}");
e
})?;
// write config after setting value // write config after setting value
self.config.lock().await.write(); self.config.lock().await.write();
@@ -515,7 +495,7 @@ pub async fn set_config_or_default(
) { ) {
for attr in attrs.attributes().iter() { for attr in attrs.attributes().iter() {
let name: FirmwareAttribute = attr.name().into(); let name: FirmwareAttribute = attr.name().into();
if name.is_ppt() || name.is_dgpu() { if name.property_type() == FirmwareAttributeType::Ppt {
let tuning = config.select_tunings(power_plugged, profile); let tuning = config.select_tunings(power_plugged, profile);
if !tuning.enabled { if !tuning.enabled {
debug!("Tuning group is not enabled, skipping"); debug!("Tuning group is not enabled, skipping");

View File

@@ -4,7 +4,9 @@ use std::sync::Arc;
use config_traits::StdConfig; use config_traits::StdConfig;
use log::{debug, error, info, warn}; use log::{debug, error, info, warn};
use rog_platform::asus_armoury::{AttrValue, FirmwareAttribute, FirmwareAttributes}; use rog_platform::asus_armoury::{
AttrValue, FirmwareAttribute, FirmwareAttributeType, FirmwareAttributes,
};
use rog_platform::cpu::{CPUControl, CPUGovernor, CPUEPP}; use rog_platform::cpu::{CPUControl, CPUGovernor, CPUEPP};
use rog_platform::platform::{PlatformProfile, Properties, RogPlatform}; use rog_platform::platform::{PlatformProfile, Properties, RogPlatform};
use rog_platform::power::AsusPower; use rog_platform::power::AsusPower;
@@ -617,7 +619,7 @@ impl CtrlPlatform {
for attr in self.attributes.attributes() { for attr in self.attributes.attributes() {
let name: FirmwareAttribute = attr.name().into(); let name: FirmwareAttribute = attr.name().into();
if name.is_ppt() { if name.property_type() == FirmwareAttributeType::Ppt {
// reset stored value // reset stored value
if let Some(tune) = self if let Some(tune) = self
.config .config

View File

@@ -110,6 +110,33 @@ export component MainWindow inherits Window {
if(side-bar.current-item == 5): PageAbout { if(side-bar.current-item == 5): PageAbout {
width: root.width - side-bar.width; width: root.width - side-bar.width;
} }
if toast: Rectangle {
x: 0px;
y: root.height - self.height;
width: root.width - side-bar.width;
height: 40px;
opacity: 1.0;
background: Palette.selection-background;
clip: true;
TouchArea {
height: 100%;
width: 100%;
clicked => {
toast = false;
}
}
Rectangle {
height: 100%;
width: 100%;
background: Palette.control-background;
Text {
color: Palette.control-foreground;
text: root.toast_text;
}
}
}
} }
} }
@@ -133,31 +160,6 @@ export component MainWindow inherits Window {
} }
} }
if toast: Rectangle {
x: 0px;
y: 0px;
width: root.width;
height: 32px;
opacity: 1.0;
background: Colors.grey;
TouchArea {
height: 100%;
width: 100%;
clicked => {
toast = false;
}
}
Rectangle {
height: 100%;
width: 100%;
background: Palette.control-background;
Text {
color: Palette.control-foreground;
text: root.toast_text;
}
}
}
// // TODO: or use Dialogue // // TODO: or use Dialogue
if show_notif: Rectangle { if show_notif: Rectangle {
@@ -190,7 +192,7 @@ export component MainWindow inherits Window {
y: 0px; y: 0px;
width: root.width; width: root.width;
height: root.height; height: root.height;
//padding only has effect on layout elements //padding only has effect on layout elements
//padding: 10px; //padding: 10px;

View File

@@ -253,8 +253,19 @@ impl FirmwareAttributes {
} }
} }
#[derive(Clone, Copy, Debug, PartialEq, Eq, Default)]
pub enum FirmwareAttributeType {
#[default]
Immediate,
TUFKeyboard,
Ppt,
Gpu,
Bios,
}
macro_rules! define_attribute_getters { macro_rules! define_attribute_getters {
($($attr:ident),*) => { // Accept a list of attribute idents and an optional `types { .. }` block
( $( $attr:ident ),* $(,)? $( ; types { $( $tattr:ident : $ptype:ident ),* $(,)? } )? ) => {
impl FirmwareAttributes { impl FirmwareAttributes {
$( $(
pub fn $attr(&self) -> Option<&Attribute> { pub fn $attr(&self) -> Option<&Attribute> {
@@ -268,6 +279,17 @@ macro_rules! define_attribute_getters {
}); });
)* )*
} }
impl FirmwareAttribute {
pub fn property_type(&self) -> FirmwareAttributeType {
match <&str>::from(*self) {
$(
$( stringify!($tattr) => FirmwareAttributeType::$ptype, )*
)?
_ => FirmwareAttributeType::Immediate,
}
}
}
} }
} }
@@ -299,6 +321,38 @@ define_attribute_getters!(
gpu_mux_mode, gpu_mux_mode,
mini_led_mode, mini_led_mode,
screen_auto_brightness screen_auto_brightness
; types {
ppt_pl1_spl: Ppt,
ppt_pl2_sppt: Ppt,
ppt_apu_sppt: Ppt,
ppt_platform_sppt: Ppt,
ppt_fppt: Ppt,
nv_dynamic_boost: Ppt,
nv_temp_target: Ppt,
dgpu_base_tgp: Ppt,
dgpu_tgp: Ppt,
gpu_mux_mode: Gpu,
egpu_connected: Gpu,
egpu_enable: Gpu,
dgpu_disable: Gpu,
boot_sound: Bios,
mcu_powersave: Immediate,
screen_auto_brightness: Immediate,
mini_led_mode: Immediate,
panel_hd_mode: Immediate,
panel_od: Immediate,
kbd_leds_awake: TUFKeyboard,
kbd_leds_sleep: TUFKeyboard,
kbd_leds_boot: TUFKeyboard,
kbd_leds_shutdown: TUFKeyboard,
charge_mode: Immediate,
}
); );
/// CamelCase names of the properties. Intended for use with DBUS /// CamelCase names of the properties. Intended for use with DBUS
@@ -352,29 +406,6 @@ pub enum FirmwareAttribute {
KbdLedsShutdown = 30, KbdLedsShutdown = 30,
} }
impl FirmwareAttribute {
pub fn is_ppt(&self) -> bool {
matches!(
self,
FirmwareAttribute::PptPl1Spl
| FirmwareAttribute::PptPl2Sppt
| FirmwareAttribute::PptPl3Fppt
| FirmwareAttribute::PptFppt
| FirmwareAttribute::PptApuSppt
| FirmwareAttribute::PptPlatformSppt
)
}
pub fn is_dgpu(&self) -> bool {
matches!(
self,
FirmwareAttribute::NvDynamicBoost
| FirmwareAttribute::NvTempTarget
| FirmwareAttribute::DgpuTgp
)
}
}
impl From<&str> for FirmwareAttribute { impl From<&str> for FirmwareAttribute {
fn from(s: &str) -> Self { fn from(s: &str) -> Self {
match s { match s {