Compare commits

..

5 Commits

Author SHA1 Message Date
Luke D. Jones
bddccc696f Update deps 2025-01-21 19:49:20 +13:00
Luke D. Jones
51e9f10087 Prep 6.1.0-rc7 2025-01-21 16:44:58 +13:00
Luke D. Jones
911ff8690e 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
2025-01-21 16:39:34 +13:00
Luke D. Jones
25823dc6b7 asusd: anime: don't cause async deadlocks damnit
Same old song, an async mutex lock being held for a wide scope.
In particular being held for a scope that includes a function call which
also tries to get the lock.

Fix it by copy/clone of the config interior values required.

Fixes #588
2025-01-21 12:24:24 +13:00
Luke D. Jones
cba8e1a473 Add extra debug logging to anime path 2025-01-20 13:43:38 +13:00
22 changed files with 836 additions and 539 deletions

View File

@@ -2,6 +2,15 @@
## [Unreleased]
## [v6.1.0-rc7]
- 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
- Bugfix: prevent an AniMe thread async deadlock
## [v6.1.0-rc6]
### Changed

728
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,5 @@
[workspace.package]
version = "6.1.0-rc6"
version = "6.1.0-rc7"
rust-version = "1.82"
license = "MPL-2.0"
readme = "README.md"

View File

@@ -74,7 +74,15 @@ fn main() {
println!("\nError: {e}\n");
print_info();
}) {
let asusd_version = platform_proxy.version().unwrap();
let asusd_version = platform_proxy
.version()
.map_err(|e| {
error!(
"Could not get asusd version: {e:?}\nIs asusd.service running? {}",
check_service("asusd")
);
})
.unwrap();
if asusd_version != self_version {
println!("Version mismatch: asusctl = {self_version}, asusd = {asusd_version}");
return;

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

@@ -8,7 +8,7 @@ use std::sync::Arc;
use std::thread::sleep;
use config_traits::StdConfig;
use log::{error, info, warn};
use log::{debug, error, info, warn};
use rog_anime::usb::{
pkt_flush, pkt_set_brightness, pkt_set_enable_display, pkt_set_enable_powersave_anim,
pkts_for_init, Brightness
@@ -16,7 +16,7 @@ use rog_anime::usb::{
use rog_anime::{ActionData, AnimeDataBuffer, AnimePacketType};
use rog_platform::hid_raw::HidRaw;
use rog_platform::usb_raw::USBRaw;
use tokio::sync::{Mutex, MutexGuard};
use tokio::sync::Mutex;
use self::config::{AniMeConfig, AniMeConfigCached};
use crate::error::RogError;
@@ -59,6 +59,8 @@ impl AniMe {
config.rename_file_old();
*config = AniMeConfig::new();
config.write();
} else {
debug!("Initialised AniMe cache");
}
} else {
error!("AniMe Matrix could not init cache")
@@ -70,11 +72,9 @@ impl AniMe {
self.do_init_cache().await;
let pkts = pkts_for_init();
self.write_bytes(&pkts[0]).await?;
self.write_bytes(&pkts[1]).await
}
pub async fn lock_config(&self) -> MutexGuard<AniMeConfig> {
self.config.lock().await
self.write_bytes(&pkts[1]).await?;
debug!("Succesfully initialised AniMe matrix display");
Ok(())
}
pub async fn write_bytes(&self, message: &[u8]) -> Result<(), RogError> {
@@ -227,10 +227,11 @@ impl AniMe {
})
.ok();
}
// A write can block for many milliseconds so lets not hold the config lock for
// the same period
let enabled = inner.config.lock().await.builtin_anims_enabled;
inner
.write_bytes(&pkt_set_enable_powersave_anim(
inner.config.lock().await.builtin_anims_enabled
))
.write_bytes(&pkt_set_enable_powersave_anim(enabled))
.await
.map_err(|err| {
warn!("rog_anime::run_animation:callback {}", err);

View File

@@ -1,7 +1,7 @@
use std::sync::atomic::Ordering;
use config_traits::StdConfig;
use log::{error, warn};
use log::{debug, error, warn};
use logind_zbus::manager::ManagerProxy;
use rog_anime::usb::{
pkt_set_brightness, pkt_set_builtin_animations, pkt_set_enable_display,
@@ -51,8 +51,11 @@ impl AniMeZbus {
.object_server()
.at(path.clone(), self)
.await
.map_err(|e| error!("Couldn't add server at path: {path}, {e:?}"))
.ok();
.map_err(|e| {
error!("Couldn't add server at path: {path}, {e:?}");
e
})?;
debug!("start_tasks was successful");
Ok(())
}
}
@@ -440,50 +443,60 @@ impl crate::CtrlTask for AniMeZbus {
impl crate::Reloadable for AniMeZbus {
async fn reload(&mut self) -> Result<(), RogError> {
if let Ok(config) = self.0.config.try_lock() {
let anim = &config.builtin_anims;
// Set builtins
if config.builtin_anims_enabled {
self.0
.write_bytes(&pkt_set_builtin_animations(
anim.boot, anim.awake, anim.sleep, anim.shutdown
))
.await?;
}
// Builtins enabled or na?
let AniMeConfig {
builtin_anims_enabled,
builtin_anims,
display_enabled,
display_brightness,
off_when_lid_closed,
off_when_unplugged,
..
} = *self.0.config.lock().await;
// Set builtins
if builtin_anims_enabled {
self.0
.set_builtins_enabled(config.builtin_anims_enabled, config.display_brightness)
.write_bytes(&pkt_set_builtin_animations(
builtin_anims.boot,
builtin_anims.awake,
builtin_anims.sleep,
builtin_anims.shutdown
))
.await?;
}
// Builtins enabled or na?
self.0
.set_builtins_enabled(builtin_anims_enabled, display_brightness)
.await?;
let manager = get_logind_manager().await;
let lid_closed = manager.lid_closed().await.unwrap_or_default();
let power_plugged = manager.on_external_power().await.unwrap_or_default();
let manager = get_logind_manager().await;
let lid_closed = manager.lid_closed().await.unwrap_or_default();
let power_plugged = manager.on_external_power().await.unwrap_or_default();
let turn_off = (lid_closed && config.off_when_lid_closed)
|| (!power_plugged && config.off_when_unplugged);
let turn_off =
(lid_closed && off_when_lid_closed) || (!power_plugged && off_when_unplugged);
self.0
.write_bytes(&pkt_set_enable_display(!turn_off))
.await
.map_err(|err| {
warn!("create_sys_event_tasks::reload {}", err);
})
.ok();
if turn_off || !display_enabled {
self.0.write_bytes(&pkt_set_enable_display(false)).await?;
// early return so we don't run animation thread
return Ok(());
}
if !builtin_anims_enabled && !self.0.cache.boot.is_empty() {
self.0
.write_bytes(&pkt_set_enable_display(!turn_off))
.write_bytes(&pkt_set_enable_powersave_anim(false))
.await
.map_err(|err| {
warn!("create_sys_event_tasks::reload {}", err);
})
.ok();
if turn_off || !config.display_enabled {
self.0.write_bytes(&pkt_set_enable_display(false)).await?;
// early return so we don't run animation thread
return Ok(());
}
if !config.builtin_anims_enabled && !self.0.cache.boot.is_empty() {
self.0
.write_bytes(&pkt_set_enable_powersave_anim(false))
.await
.ok();
let action = self.0.cache.boot.clone();
self.0.run_thread(action, true).await;
}
let action = self.0.cache.boot.clone();
self.0.run_thread(action, true).await;
}
Ok(())
}

View File

@@ -319,11 +319,17 @@ impl DeviceManager {
if let DeviceHandle::AniMe(anime) = dev_type.clone() {
let path = dbus_path_for_anime();
let ctrl = AniMeZbus::new(anime);
ctrl.start_tasks(connection, path.clone()).await.unwrap();
devices.push(AsusDevice {
device: dev_type,
dbus_path: path
});
if ctrl
.start_tasks(connection, path.clone())
.await
.map_err(|e| error!("Failed to start tasks: {e:?}, not adding this device"))
.is_ok()
{
devices.push(AsusDevice {
device: dev_type,
dbus_path: path
});
}
}
} else {
info!("Tested device was not AniMe Matrix");
@@ -364,7 +370,9 @@ impl DeviceManager {
pub async fn new(connection: Connection) -> Result<Self, RogError> {
let conn_copy = connection.clone();
let devices = Arc::new(Mutex::new(Self::find_all_devices(&conn_copy).await));
let devices = Self::find_all_devices(&conn_copy).await;
info!("Found {} valid devices on startup", devices.len());
let devices = Arc::new(Mutex::new(devices));
let manager = Self {
_dbus_connection: connection
};
@@ -372,8 +380,6 @@ impl DeviceManager {
// TODO: The /sysfs/ LEDs don't cause events, so they need to be manually
// checked for and added
// detect all plugged in aura devices (eventually)
// only USB devices are detected for here
std::thread::spawn(move || {
let mut monitor = MonitorBuilder::new()?.listen()?;
let mut poll = Poll::new()?;
@@ -420,7 +426,10 @@ impl DeviceManager {
{
index
} else {
warn!("No device for dbus path: {path:?}");
if dev_prop_matches(&event.device(), "ID_VENDOR_ID", "0b05")
{
warn!("No device for dbus path: {path:?}");
}
return Ok(());
};
info!("removing: {path:?}");

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)?
@@ -100,6 +112,7 @@ async fn start_daemon() -> Result<(), Box<dyn Error>> {
// Request dbus name after finishing initalizing all functions
server.request_name(DBUS_NAME).await?;
info!("Startup success, begining dbus server loop");
loop {
// This is just a blocker to idle and ensure the reator reacts
server.executor().tick().await;

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

@@ -49,7 +49,12 @@ async fn main() -> Result<()> {
let self_version = env!("CARGO_PKG_VERSION");
let zbus_con = zbus::blocking::Connection::system()?;
let platform_proxy = rog_dbus::zbus_platform::PlatformProxyBlocking::new(&zbus_con)?;
let asusd_version = platform_proxy.version().unwrap();
let asusd_version = platform_proxy
.version()
.map_err(|e| {
println!("Could not get asusd version: {e:?}\nIs asusd.service running?");
})
.unwrap();
if asusd_version != self_version {
println!("Version mismatch: asusctl = {self_version}, asusd = {asusd_version}");
return Ok(());

View File

@@ -208,7 +208,15 @@ pub fn init_tray(_supported_properties: Vec<Properties>, config: Arc<Mutex<Confi
}
}
}
Err(e) => warn!("Couldn't get mode form supergfxd: {e:?}")
Err(e) => match e {
zbus::Error::MethodError(_, _, message) => {
warn!(
"Couldn't get mode from supergfxd: {message:?}, the supergfxd service \
may not be running or installed"
)
}
_ => warn!("Couldn't get mode from supergfxd: {e:?}")
}
}
info!("Started ROGTray");

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(|e| 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-19 10:35+0000\n"
"POT-Creation-Date: 2025-01-21 06:49+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
msgctxt "no_asus_armoury_driver_2"
#: 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_2" => "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");