feature: rework PPT tuning handling more

1. Per profile, per-ac/dc
2. Do not apply unless group is enabled
3. Better reset/disable handling
4. Selecting a profile defaults PPT to off/disabled
This commit is contained in:
Luke D. Jones
2025-01-20 22:03:39 +13:00
parent 25823dc6b7
commit 911ff8690e
14 changed files with 351 additions and 122 deletions

View File

@@ -2,6 +2,12 @@
## [Unreleased]
- Refactor PPT handling more:
1. Per profile, per-ac/dc
2. Do not apply unless group is enabled
3. Better reset/disable handling
4. Selecting a profile defaults PPT to off/disabled
## [v6.1.0-rc6]
### Changed

View File

@@ -113,15 +113,18 @@ impl crate::Reloadable for AsusArmouryAttribute {
} else {
&self.config.lock().await.dc_profile_tunings
};
if let Some(tunings) = config.get(&profile) {
if let Some(tune) = tunings.get(&self.name()) {
self.attr
.set_current_value(&AttrValue::Integer(*tune))
.map_err(|e| {
error!("Could not set value: {e:?}");
e
})?;
info!("Set {} to {:?}", self.attr.name(), tune);
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);
}
}
}
@@ -191,12 +194,20 @@ impl AsusArmouryAttribute {
.unwrap_or_default();
let mut config = self.config.lock().await;
let tunings = config.select_tunings(power_plugged == 1, profile);
if let Some(tune) = tunings.get_mut(&self.name()) {
let tuning = config.select_tunings(power_plugged == 1, profile);
if let Some(tune) = tuning.group.get_mut(&self.name()) {
if let AttrValue::Integer(i) = self.attr.default_value() {
*tune = *i;
}
}
if tuning.enabled {
self.attr
.set_current_value(self.attr.default_value())
.map_err(|e| {
error!("Could not set value: {e:?}");
e
})?;
}
config.write();
}
Ok(())
@@ -236,6 +247,28 @@ impl AsusArmouryAttribute {
#[zbus(property)]
async fn current_value(&self) -> fdo::Result<i32> {
if self.name().is_ppt() {
let profile: PlatformProfile = self.platform.get_platform_profile()?.into();
let power_plugged = self
.power
.get_online()
.map_err(|e| {
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() {
return Ok(*i);
}
return Err(fdo::Error::Failed(
"Could not read current value".to_string()
));
}
if let Ok(AttrValue::Integer(i)) = self.attr.current_value() {
return Ok(i);
}
@@ -246,16 +279,8 @@ impl AsusArmouryAttribute {
#[zbus(property)]
async fn set_current_value(&mut self, value: i32) -> fdo::Result<()> {
self.attr
.set_current_value(&AttrValue::Integer(value))
.map_err(|e| {
error!("Could not set value: {e:?}");
e
})?;
if self.name().is_ppt() {
let profile: PlatformProfile = self.platform.get_platform_profile()?.into();
let power_plugged = self
.power
.get_online()
@@ -264,16 +289,32 @@ impl AsusArmouryAttribute {
e
})
.unwrap_or_default();
let mut config = self.config.lock().await;
let tunings = config.select_tunings(power_plugged == 1, profile);
if let Some(tune) = tunings.get_mut(&self.name()) {
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 {
tunings.insert(self.name(), value);
debug!("Set tuning config for {} = {:?}", self.attr.name(), value);
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| {
error!("Could not set value: {e:?}");
e
})?;
}
} else {
self.attr
.set_current_value(&AttrValue::Integer(value))
.map_err(|e| {
error!("Could not set value: {e:?}");
e
})?;
let has_attr = self
.config
.lock()
@@ -309,9 +350,10 @@ pub async fn start_attributes_zbus(
conn: &Connection,
platform: RogPlatform,
power: AsusPower,
attributes: FirmwareAttributes,
config: Arc<Mutex<Config>>
) -> Result<(), RogError> {
for attr in FirmwareAttributes::new().attributes() {
for attr in attributes.attributes() {
let mut attr = AsusArmouryAttribute::new(
attr.clone(),
platform.clone(),
@@ -338,9 +380,13 @@ pub async fn set_config_or_default(
for attr in attrs.attributes().iter() {
let name: FirmwareAttribute = attr.name().into();
if name.is_ppt() {
let tunings = config.select_tunings(power_plugged, profile);
let tuning = config.select_tunings(power_plugged, profile);
if !tuning.enabled {
debug!("Tuning group is not enabled, skipping");
return;
}
if let Some(tune) = tunings.get(&name) {
if let Some(tune) = tuning.group.get(&name) {
attr.set_current_value(&AttrValue::Integer(*tune))
.map_err(|e| {
error!("Failed to set {}: {e}", <&str>::from(name));
@@ -354,7 +400,7 @@ pub async fn set_config_or_default(
})
.ok();
if let AttrValue::Integer(i) = default {
tunings.insert(name, *i);
tuning.group.insert(name, *i);
info!(
"Set default tuning config for {} = {:?}",
<&str>::from(name),

View File

@@ -7,7 +7,13 @@ use rog_platform::platform::PlatformProfile;
use serde::{Deserialize, Serialize};
const CONFIG_FILE: &str = "asusd.ron";
type Tunings = HashMap<PlatformProfile, HashMap<FirmwareAttribute, i32>>;
#[derive(Default, Clone, Deserialize, Serialize, PartialEq)]
pub struct Tuning {
pub enabled: bool,
pub group: HashMap<FirmwareAttribute, i32>
}
type Tunings = HashMap<PlatformProfile, Tuning>;
#[derive(Deserialize, Serialize, PartialEq)]
pub struct Config {
@@ -47,17 +53,13 @@ pub struct Config {
}
impl Config {
pub fn select_tunings(
&mut self,
power_plugged: bool,
profile: PlatformProfile
) -> &mut HashMap<FirmwareAttribute, i32> {
pub fn select_tunings(&mut self, power_plugged: bool, profile: PlatformProfile) -> &mut Tuning {
let config = if power_plugged {
&mut self.ac_profile_tunings
} else {
&mut self.dc_profile_tunings
};
config.entry(profile).or_insert_with(HashMap::new)
config.entry(profile).or_insert_with(Tuning::default)
}
}

View File

@@ -4,7 +4,7 @@ use std::sync::Arc;
use config_traits::StdConfig;
use log::{debug, error, info, warn};
use rog_platform::asus_armoury::FirmwareAttributes;
use rog_platform::asus_armoury::{AttrValue, FirmwareAttribute, FirmwareAttributes};
use rog_platform::cpu::{CPUControl, CPUGovernor, CPUEPP};
use rog_platform::platform::{PlatformProfile, Properties, RogPlatform};
use rog_platform::power::AsusPower;
@@ -43,24 +43,27 @@ macro_rules! platform_get_value {
pub struct CtrlPlatform {
power: AsusPower,
platform: RogPlatform,
attributes: FirmwareAttributes,
cpu_control: Option<CPUControl>,
config: Arc<Mutex<Config>>
}
impl CtrlPlatform {
pub fn new(
platform: RogPlatform,
power: AsusPower,
attributes: FirmwareAttributes,
config: Arc<Mutex<Config>>,
config_path: &Path,
signal_context: SignalEmitter<'static>
) -> Result<Self, RogError> {
let platform = RogPlatform::new()?;
let power = AsusPower::new()?;
let config1 = config.clone();
let config_path = config_path.to_owned();
let ret_self = CtrlPlatform {
power,
platform,
attributes,
config,
cpu_control: CPUControl::new()
.map_err(|e| error!("Couldn't get CPU control sysfs: {e}"))
@@ -332,6 +335,7 @@ impl CtrlPlatform {
warn!("platform_profile {}", err);
FdoErr::Failed(format!("RogPlatform: platform_profile: {err}"))
})?;
self.enable_ppt_group_changed(&ctxt).await?;
Ok(self.platform_profile_changed(&ctxt).await?)
} else {
Err(FdoErr::NotSupported(
@@ -352,6 +356,21 @@ impl CtrlPlatform {
let change_epp = self.config.lock().await.platform_profile_linked_epp;
let epp = self.get_config_epp_for_throttle(policy).await;
self.check_and_set_epp(epp, change_epp);
let power_plugged = self
.power
.get_online()
.map_err(|e| {
error!("Could not get power status: {e:?}");
e
})
.unwrap_or_default();
self.config
.lock()
.await
.select_tunings(power_plugged == 1, policy)
.enabled = false;
self.config.lock().await.write();
self.platform
.set_platform_profile(policy.into())
@@ -475,9 +494,96 @@ impl CtrlPlatform {
let change_pp = self.config.lock().await.platform_profile_linked_epp;
self.config.lock().await.profile_performance_epp = epp;
self.check_and_set_epp(epp, change_pp);
self.config.lock().await.write();
Ok(())
}
/// Set if the PPT tuning group for the current profile is enabled
#[zbus(property)]
async fn enable_ppt_group(&self) -> Result<bool, FdoErr> {
let power_plugged = self
.power
.get_online()
.map_err(|e| {
error!("Could not get power status: {e:?}");
e
})
.unwrap_or_default();
let profile: PlatformProfile = self.platform.get_platform_profile()?.into();
Ok(self
.config
.lock()
.await
.select_tunings(power_plugged == 1, profile)
.enabled)
}
/// Set if the PPT tuning group for the current profile is enabled
#[zbus(property)]
async fn set_enable_ppt_group(&mut self, enable: bool) -> Result<(), FdoErr> {
let power_plugged = self
.power
.get_online()
.map_err(|e| {
error!("Could not get power status: {e:?}");
e
})
.unwrap_or_default();
let profile: PlatformProfile = self.platform.get_platform_profile()?.into();
// Clone to reduce blocking
let tuning = self
.config
.lock()
.await
.select_tunings(power_plugged == 1, profile)
.clone();
for attr in self.attributes.attributes() {
let name: FirmwareAttribute = attr.name().into();
if name.is_ppt() {
// reset stored value
if let Some(tune) = self
.config
.lock()
.await
.select_tunings(power_plugged == 1, profile)
.group
.get_mut(&name)
{
let value = if !enable {
attr.default_value().clone()
} else {
tuning
.group
.get(&name)
.map(|v| AttrValue::Integer(*v))
.unwrap_or_else(|| attr.default_value().clone())
};
// restore default
attr.set_current_value(&value)?;
if let AttrValue::Integer(i) = value {
*tune = i
}
}
}
}
if !enable {
// finally, reapply the profile to ensure acpi does the thingy
self.platform.set_platform_profile(profile.into())?;
}
self.config
.lock()
.await
.select_tunings(power_plugged == 1, profile)
.enabled = enable;
self.config.lock().await.write();
Ok(())
}
}
impl crate::ZbusRun for CtrlPlatform {
@@ -665,6 +771,7 @@ impl CtrlTask for CtrlPlatform {
error!("Platform: get_platform_profile error: {e}");
})
{
// TODO: manage this better, shouldn't need to create every time
let attrs = FirmwareAttributes::new();
set_config_or_default(
&attrs,
@@ -709,6 +816,7 @@ impl CtrlTask for CtrlPlatform {
let epp = ctrl.get_config_epp_for_throttle(profile).await;
ctrl.check_and_set_epp(epp, change_epp);
ctrl.platform_profile_changed(&signal_ctxt).await.ok();
ctrl.enable_ppt_group_changed(&signal_ctxt).await.ok();
let power_plugged = ctrl
.power
.get_online()

View File

@@ -12,6 +12,7 @@ use asusd::ctrl_platform::CtrlPlatform;
use asusd::{print_board_info, start_tasks, CtrlTask, DBUS_NAME};
use config_traits::{StdConfig, StdConfigLoad1};
use log::{error, info};
use rog_platform::asus_armoury::FirmwareAttributes;
use rog_platform::platform::RogPlatform;
use rog_platform::power::AsusPower;
use zbus::fdo::ObjectManager;
@@ -69,7 +70,15 @@ async fn start_daemon() -> Result<(), Box<dyn Error>> {
// supported.add_to_server(&mut connection).await;
let platform = RogPlatform::new()?; // TODO: maybe needs async mutex?
let power = AsusPower::new()?; // TODO: maybe needs async mutex?
start_attributes_zbus(&server, platform, power, config.clone()).await?;
let attributes = FirmwareAttributes::new();
start_attributes_zbus(
&server,
platform.clone(),
power.clone(),
attributes.clone(),
config.clone()
)
.await?;
match CtrlFanCurveZbus::new() {
Ok(ctrl) => {
@@ -82,6 +91,9 @@ async fn start_daemon() -> Result<(), Box<dyn Error>> {
}
match CtrlPlatform::new(
platform,
power,
attributes,
config.clone(),
&cfg_path,
CtrlPlatform::signal_context(&server)?

View File

@@ -6,7 +6,7 @@ After=nvidia-powerd.service systemd-udevd.service
[Service]
Environment=IS_SERVICE=1
Environment=RUST_LOG="info"
Environment=RUST_LOG="debug"
# required to prevent init issues with hid_asus and MCU
ExecStartPre=/bin/sleep 1
ExecStart=/usr/bin/asusd
@@ -16,3 +16,4 @@ Type=dbus
BusName=xyz.ljones.Asusd
SELinuxContext=system_u:system_r:unconfined_t:s0
#SELinuxContext=system_u:object_r:modules_object_t:s0
TimeoutSec=10

View File

@@ -1,7 +1,6 @@
[Desktop Entry]
Version=1.0
Type=Application
Name=ROG Control Center
Comment=Make your ASUS ROG Laptop go Brrrrr!
Categories=Settings

View File

@@ -6,6 +6,7 @@ pub mod setup_system;
use std::sync::{Arc, Mutex};
use config_traits::StdConfig;
use log::warn;
use rog_dbus::list_iface_blocking;
use slint::{ComponentHandle, PhysicalSize, SharedString, Weak};
@@ -82,6 +83,9 @@ pub fn show_toast(
}
pub fn setup_window(config: Arc<Mutex<Config>>) -> MainWindow {
slint::set_xdg_app_id("rog-control-center")
.map_err(warn!("Couldn't set application ID: {e:?}"))
.ok();
let ui = MainWindow::new().unwrap();
if let Ok(lock) = config.try_lock() {
let fullscreen = lock.start_fullscreen;

View File

@@ -288,9 +288,18 @@ pub fn setup_system_page_callbacks(ui: &MainWindow, _states: Arc<Mutex<Config>>)
change_platform_profile_on_ac
);
set_ui_props_async!(handle, platform, SystemPageData, enable_ppt_group);
let platform_copy = platform.clone();
handle
.upgrade_in_event_loop(move |handle| {
set_ui_callbacks!(handle,
SystemPageData(as bool),
platform_copy.enable_ppt_group(as bool),
"Applied PPT group settings {}",
"Setting PPT group settings failed"
);
set_ui_callbacks!(handle,
SystemPageData(as f32),
platform_copy.charge_control_end_threshold(as u8),

View File

@@ -2,7 +2,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2025-01-20 00:43+0000\n"
"POT-Creation-Date: 2025-01-21 03:38+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -47,198 +47,203 @@ msgctxt "SystemPageData"
msgid "Power"
msgstr ""
#: rog-control-center/ui/pages/system.slint:139
#: rog-control-center/ui/pages/system.slint:142
msgctxt "PageSystem"
msgid "Power settings"
msgstr ""
#: rog-control-center/ui/pages/system.slint:144
#: rog-control-center/ui/pages/system.slint:147
msgctxt "PageSystem"
msgid "Charge limit"
msgstr ""
#: rog-control-center/ui/pages/system.slint:158
#: rog-control-center/ui/pages/system.slint:161
msgctxt "PageSystem"
msgid "Platform Profile"
msgstr ""
#: rog-control-center/ui/pages/system.slint:168
#: rog-control-center/ui/pages/system.slint:171
msgctxt "PageSystem"
msgid "Advanced"
msgstr ""
#: rog-control-center/ui/pages/system.slint:186
#: rog-control-center/ui/pages/system.slint:189
msgctxt "PageSystem"
msgid "Armoury settings"
msgstr ""
#: rog-control-center/ui/pages/system.slint:194
msgctxt "PageSystem"
msgid "Panel Overdrive"
msgstr ""
#: rog-control-center/ui/pages/system.slint:202
msgctxt "PageSystem"
msgid "MiniLED Mode"
msgstr ""
#: rog-control-center/ui/pages/system.slint:210
msgctxt "PageSystem"
msgid "POST boot sound"
msgstr ""
#: rog-control-center/ui/pages/system.slint:224
#: rog-control-center/ui/pages/system.slint:199
msgctxt "no_asus_armoury_driver_1"
msgid "The asus-armoury driver is not loaded"
msgstr ""
#: rog-control-center/ui/pages/system.slint:230
#: rog-control-center/ui/pages/system.slint:205
msgctxt "no_asus_armoury_driver_2"
msgid "For advanced features you will require a kernel with this driver added."
msgstr ""
#: rog-control-center/ui/pages/system.slint:241
msgctxt "ppt_warning"
msgid "The following settings may not be safe, please review the help."
#: rog-control-center/ui/pages/system.slint:216
msgctxt "PageSystem"
msgid "Panel Overdrive"
msgstr ""
#: rog-control-center/ui/pages/system.slint:246 rog-control-center/ui/pages/system.slint:247
#: rog-control-center/ui/pages/system.slint:224
msgctxt "PageSystem"
msgid "MiniLED Mode"
msgstr ""
#: rog-control-center/ui/pages/system.slint:232
msgctxt "PageSystem"
msgid "POST boot sound"
msgstr ""
#: rog-control-center/ui/pages/system.slint:248
msgctxt "ppt_warning"
msgid "The following settings are not applied until the toggle is enabled."
msgstr ""
#: rog-control-center/ui/pages/system.slint:253
msgctxt "ppt_group_enabled"
msgid "Enable Tuning"
msgstr ""
#: rog-control-center/ui/pages/system.slint:262 rog-control-center/ui/pages/system.slint:263
msgctxt "ppt_pl1_spl"
msgid "CPU Sustained Power Limit"
msgstr ""
#: rog-control-center/ui/pages/system.slint:248
#: rog-control-center/ui/pages/system.slint:264
msgctxt "ppt_pl1_spl_help"
msgid ""
"Long-term CPU power limit that affects sustained workload performance. "
"Higher values may increase heat and power consumption."
msgstr ""
#: rog-control-center/ui/pages/system.slint:263 rog-control-center/ui/pages/system.slint:264
#: rog-control-center/ui/pages/system.slint:279 rog-control-center/ui/pages/system.slint:280
msgctxt "ppt_pl2_sppt"
msgid "CPU Turbo Power Limit"
msgstr ""
#: rog-control-center/ui/pages/system.slint:265
#: rog-control-center/ui/pages/system.slint:281
msgctxt "ppt_pl2_sppt_help"
msgid ""
"Short-term CPU power limit for boost periods. Controls maximum power during "
"brief high-performance bursts."
msgstr ""
#: rog-control-center/ui/pages/system.slint:280 rog-control-center/ui/pages/system.slint:281
#: rog-control-center/ui/pages/system.slint:296 rog-control-center/ui/pages/system.slint:297
msgctxt "ppt_pl3_fppt"
msgid "CPU Fast Burst Power Limit"
msgstr ""
#: rog-control-center/ui/pages/system.slint:282
#: rog-control-center/ui/pages/system.slint:298
msgctxt "ppt_pl3_fppt_help"
msgid ""
"Ultra-short duration power limit for instantaneous CPU bursts. Affects "
"responsiveness during sudden workload spikes."
msgstr ""
#: rog-control-center/ui/pages/system.slint:296 rog-control-center/ui/pages/system.slint:297
#: rog-control-center/ui/pages/system.slint:312 rog-control-center/ui/pages/system.slint:313
msgctxt "ppt_fppt"
msgid "Fast Package Power Limit"
msgstr ""
#: rog-control-center/ui/pages/system.slint:298
#: rog-control-center/ui/pages/system.slint:314
msgctxt "ppt_fppt_help"
msgid ""
"Ultra-short duration power limit for system package. Controls maximum power "
"during millisecond-scale load spikes."
msgstr ""
#: rog-control-center/ui/pages/system.slint:313 rog-control-center/ui/pages/system.slint:314
#: rog-control-center/ui/pages/system.slint:329 rog-control-center/ui/pages/system.slint:330
msgctxt "ppt_apu_sppt"
msgid "APU Sustained Power Limit"
msgstr ""
#: rog-control-center/ui/pages/system.slint:315
#: rog-control-center/ui/pages/system.slint:331
msgctxt "ppt_apu_sppt_help"
msgid ""
"Long-term power limit for integrated graphics and CPU combined. Affects "
"sustained performance of APU-based workloads."
msgstr ""
#: rog-control-center/ui/pages/system.slint:330 rog-control-center/ui/pages/system.slint:331
#: rog-control-center/ui/pages/system.slint:346 rog-control-center/ui/pages/system.slint:347
msgctxt "ppt_platform_sppt"
msgid "Platform Sustained Power Limit"
msgstr ""
#: rog-control-center/ui/pages/system.slint:332
#: rog-control-center/ui/pages/system.slint:348
msgctxt "ppt_platform_sppt_help"
msgid ""
"Overall system power limit for sustained operations. Controls total platform "
"power consumption over extended periods."
msgstr ""
#: rog-control-center/ui/pages/system.slint:347 rog-control-center/ui/pages/system.slint:348
#: rog-control-center/ui/pages/system.slint:363 rog-control-center/ui/pages/system.slint:364
msgctxt "nv_dynamic_boost"
msgid "GPU Power Boost"
msgstr ""
#: rog-control-center/ui/pages/system.slint:349
#: rog-control-center/ui/pages/system.slint:365
msgctxt "nv_dynamic_boost_help"
msgid ""
"Additional power allocation for GPU dynamic boost. Higher values increase "
"GPU performance but generate more heat."
msgstr ""
#: rog-control-center/ui/pages/system.slint:364 rog-control-center/ui/pages/system.slint:365
#: rog-control-center/ui/pages/system.slint:380 rog-control-center/ui/pages/system.slint:381
msgctxt "nv_temp_target"
msgid "GPU Temperature Limit"
msgstr ""
#: rog-control-center/ui/pages/system.slint:366
#: rog-control-center/ui/pages/system.slint:382
msgctxt "nv_temp_target_help"
msgid ""
"Maximum GPU temperature threshold in Celsius. GPU will throttle to maintain "
"temperature below this limit."
msgstr ""
#: rog-control-center/ui/pages/system.slint:417
#: rog-control-center/ui/pages/system.slint:433
msgctxt "PageSystem"
msgid "Energy Performance Preference linked to Throttle Policy"
msgstr ""
#: rog-control-center/ui/pages/system.slint:421
#: rog-control-center/ui/pages/system.slint:437
msgctxt "PageSystem"
msgid "Change EPP based on Throttle Policy"
msgstr ""
#: rog-control-center/ui/pages/system.slint:429
#: rog-control-center/ui/pages/system.slint:445
msgctxt "PageSystem"
msgid "EPP for Balanced Policy"
msgstr ""
#: rog-control-center/ui/pages/system.slint:439
#: rog-control-center/ui/pages/system.slint:455
msgctxt "PageSystem"
msgid "EPP for Performance Policy"
msgstr ""
#: rog-control-center/ui/pages/system.slint:449
#: rog-control-center/ui/pages/system.slint:465
msgctxt "PageSystem"
msgid "EPP for Quiet Policy"
msgstr ""
#: rog-control-center/ui/pages/system.slint:467
#: rog-control-center/ui/pages/system.slint:483
msgctxt "PageSystem"
msgid "Throttle Policy for power state"
msgstr ""
#: rog-control-center/ui/pages/system.slint:473
#: rog-control-center/ui/pages/system.slint:489
msgctxt "PageSystem"
msgid "Throttle Policy on Battery"
msgstr ""
#: rog-control-center/ui/pages/system.slint:483 rog-control-center/ui/pages/system.slint:504
#: rog-control-center/ui/pages/system.slint:499 rog-control-center/ui/pages/system.slint:520
msgctxt "PageSystem"
msgid "Enabled"
msgstr ""
#: rog-control-center/ui/pages/system.slint:494
#: rog-control-center/ui/pages/system.slint:510
msgctxt "PageSystem"
msgid "Throttle Policy on AC"
msgstr ""
@@ -728,42 +733,42 @@ msgctxt "confirm_reset"
msgid "Are you sure you want to reset this?"
msgstr ""
#: rog-control-center/ui/main_window.slint:51
#: rog-control-center/ui/main_window.slint:54
msgctxt "MainWindow"
msgid "ROG"
msgstr ""
#: rog-control-center/ui/main_window.slint:53
#: rog-control-center/ui/main_window.slint:56
msgctxt "Menu1"
msgid "System Control"
msgstr ""
#: rog-control-center/ui/main_window.slint:54
#: rog-control-center/ui/main_window.slint:57
msgctxt "Menu2"
msgid "Keyboard Aura"
msgstr ""
#: rog-control-center/ui/main_window.slint:55
#: rog-control-center/ui/main_window.slint:58
msgctxt "Menu3"
msgid "AniMe Matrix"
msgstr ""
#: rog-control-center/ui/main_window.slint:56
#: rog-control-center/ui/main_window.slint:59
msgctxt "Menu4"
msgid "Fan Curves"
msgstr ""
#: rog-control-center/ui/main_window.slint:57
#: rog-control-center/ui/main_window.slint:60
msgctxt "Menu5"
msgid "App Settings"
msgstr ""
#: rog-control-center/ui/main_window.slint:58
#: rog-control-center/ui/main_window.slint:61
msgctxt "Menu6"
msgid "About"
msgstr ""
#: rog-control-center/ui/main_window.slint:70
#: rog-control-center/ui/main_window.slint:73
msgctxt "MainWindow"
msgid "Quit App"
msgstr ""

View File

@@ -19,7 +19,10 @@ export { AppSize, AttrMinMax, SystemPageData, AnimePageData, AppSettingsPageData
export component MainWindow inherits Window {
title: "ROG Control";
default-font-family: "DejaVu Sans";
default-font-family: "Noto Sans";
default-font-size: 14px;
default-font-weight: 400;
icon: @image-url("../data/rog-control-center.png");
in property <[bool]> sidebar_items_avilable: [true, true, true, true, true, true];
private property <bool> show_notif;
private property <bool> fade_cover;

View File

@@ -1,5 +1,5 @@
import { SystemSlider, SystemDropdown, SystemToggle, SystemToggleInt } from "../widgets/common.slint";
import { Palette, HorizontalBox , VerticalBox, ScrollView, Slider, Button, Switch, ComboBox, GroupBox} from "std-widgets.slint";
import { Palette, HorizontalBox , VerticalBox, ScrollView, Slider, Button, Switch, ComboBox, GroupBox, StandardButton} from "std-widgets.slint";
export struct AttrMinMax {
min: int,
@@ -114,6 +114,9 @@ export global SystemPageData {
};
callback cb_nv_temp_target(int);
callback cb_default_nv_temp_target();
in-out property <bool> enable_ppt_group;
callback cb_enable_ppt_group(bool);
}
export component PageSystem inherits Rectangle {
@@ -187,6 +190,25 @@ export component PageSystem inherits Rectangle {
}
}
if !SystemPageData.asus_armoury_loaded: Rectangle {
border-width: 3px;
border-color: red;
max-height: 30px;
VerticalBox {
Text {
text: @tr("no_asus_armoury_driver_1" => "The asus-armoury driver is not loaded");
font-size: 16px;
horizontal-alignment: TextHorizontalAlignment.center;
}
Text {
text: @tr("no_asus_armoury_driver_2" => "For advanced features you will require a kernel with this driver added.");
font-size: 16px;
horizontal-alignment: TextHorizontalAlignment.center;
}
}
}
HorizontalBox {
padding: 0px;
spacing: 10px;
@@ -215,30 +237,24 @@ export component PageSystem inherits Rectangle {
}
}
if !SystemPageData.asus_armoury_loaded: Rectangle {
border-width: 3px;
border-color: red;
max-height: 30px;
VerticalBox {
if SystemPageData.ppt_pl1_spl.val != -1 || SystemPageData.ppt_pl2_sppt.val != -1 || SystemPageData.nv_dynamic_boost.val != -1: HorizontalLayout {
padding-right: 10px;
padding-left: 10px;
alignment: LayoutAlignment.space-between;
Rectangle {
height: 32px;
Text {
text: @tr("no_asus_armoury_driver_1" => "The asus-armoury driver is not loaded");
font-size: 16px;
horizontal-alignment: TextHorizontalAlignment.center;
}
Text {
text: @tr("no_asus_armoury_driver_2" => "For advanced features you will require a kernel with this driver added.");
font-size: 16px;
horizontal-alignment: TextHorizontalAlignment.center;
text: @tr("ppt_warning" => "The following settings are not applied until the toggle is enabled.");
}
}
}
if SystemPageData.ppt_pl1_spl.val != -1: Rectangle {
height: 32px;
Text {
font-size: 16px;
text: @tr("ppt_warning" => "The following settings may not be safe, please review the help.");
Switch {
text: @tr("ppt_group_enabled" => "Enable Tuning");
checked <=> SystemPageData.enable_ppt_group;
toggled => {
SystemPageData.cb_enable_ppt_group(SystemPageData.enable_ppt_group)
}
}
}
@@ -255,7 +271,7 @@ export component PageSystem inherits Rectangle {
}
released => {
SystemPageData.ppt_pl1_spl.val = self.value;
SystemPageData.cb_ppt_pl1_spl(Math.round(self.value))
SystemPageData.cb_ppt_pl1_spl(Math.round(self.value));
}
}

View File

@@ -104,4 +104,12 @@ pub trait Platform {
fn platform_profile(&self) -> zbus::Result<PlatformProfile>;
#[zbus(property)]
fn set_platform_profile(&self, platform_profile: PlatformProfile) -> zbus::Result<()>;
/// Set if the PPT tuning group for the current profile is enabled
#[zbus(property)]
fn enable_ppt_group(&self) -> zbus::Result<bool>;
/// Set if the PPT tuning group for the current profile is enabled
#[zbus(property)]
fn set_enable_ppt_group(&self, enable: bool) -> zbus::Result<()>;
}

View File

@@ -2,6 +2,7 @@ use std::fs::{read_dir, File, OpenOptions};
use std::io::{Read, Write};
use std::path::{Path, PathBuf};
use log::debug;
use serde::{Deserialize, Serialize};
use zbus::zvariant::{OwnedValue, Type, Value};
@@ -75,6 +76,15 @@ impl Attribute {
}
}
pub fn base_path_exists(&self) -> bool {
let exists = self.base_path.exists();
debug!(
"Attribute path {:?} exits? {exists}",
self.base_path.as_os_str()
);
exists
}
/// Write the `current_value` directly to the attribute path
pub fn set_current_value(&self, new_value: &AttrValue) -> Result<(), PlatformError> {
let path = self.base_path.join("current_value");