ROGCC: begin using the new asus_armoury API

This commit is contained in:
Luke D. Jones
2024-12-29 21:53:11 +13:00
parent f7456f0144
commit 4011b3ebd4
18 changed files with 702 additions and 501 deletions

View File

@@ -27,13 +27,6 @@ members = [
"rog-slash", "rog-slash",
"simulators", "rog-scsi", "simulators", "rog-scsi",
] ]
default-members = [
"asusctl",
"asusd",
"asusd-user",
"cpuctl",
"rog-control-center",
]
[workspace.dependencies] [workspace.dependencies]
tokio = { version = "^1.39.0", default-features = false, features = [ tokio = { version = "^1.39.0", default-features = false, features = [

View File

@@ -1078,7 +1078,7 @@ fn check_systemd_unit_enabled(name: &str) -> bool {
fn print_firmware_attr(attr: &AsusArmouryProxyBlocking) -> Result<(), Box<dyn std::error::Error>> { fn print_firmware_attr(attr: &AsusArmouryProxyBlocking) -> Result<(), Box<dyn std::error::Error>> {
let name = attr.name()?; let name = attr.name()?;
println!("{name}:"); println!("{}:", <&str>::from(name));
let attrs = attr.available_attrs()?; let attrs = attr.available_attrs()?;
if attrs.contains(&"min_value".to_string()) if attrs.contains(&"min_value".to_string())
@@ -1155,7 +1155,7 @@ fn handle_armoury_command(cmd: &ArmouryCommand) -> Result<(), Box<dyn std::error
for cmd in cmd.free.chunks(2) { for cmd in cmd.free.chunks(2) {
for attr in attr.iter() { for attr in attr.iter() {
let name = attr.name()?; let name = attr.name()?;
if name == cmd[0] { if <&str>::from(name) == cmd[0] {
attr.set_current_value(cmd[1].parse()?)?; attr.set_current_value(cmd[1].parse()?)?;
print_firmware_attr(attr)?; print_firmware_attr(attr)?;
} }

View File

@@ -1,5 +1,7 @@
use log::error; use log::error;
use rog_platform::firmware_attributes::{AttrValue, Attribute, FirmwareAttributes}; use rog_platform::firmware_attributes::{
AttrValue, Attribute, FirmwareAttribute, FirmwareAttributes,
};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use zbus::zvariant::{ObjectPath, OwnedObjectPath, OwnedValue, Type, Value}; use zbus::zvariant::{ObjectPath, OwnedObjectPath, OwnedValue, Type, Value};
use zbus::{fdo, interface, Connection}; use zbus::{fdo, interface, Connection};
@@ -46,8 +48,8 @@ impl AsusArmouryAttribute {
#[interface(name = "xyz.ljones.AsusArmoury")] #[interface(name = "xyz.ljones.AsusArmoury")]
impl AsusArmouryAttribute { impl AsusArmouryAttribute {
#[zbus(property)] #[zbus(property)]
async fn name(&self) -> String { async fn name(&self) -> FirmwareAttribute {
self.0.name().to_string() self.0.name().into()
} }
#[zbus(property)] #[zbus(property)]

View File

@@ -5,7 +5,6 @@ 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::cpu::{CPUControl, CPUGovernor, CPUEPP}; use rog_platform::cpu::{CPUControl, CPUGovernor, CPUEPP};
// use rog_platform::firmware_attributes::FirmwareAttributes;
use rog_platform::platform::{GpuMode, Properties, RogPlatform, ThrottlePolicy}; use rog_platform::platform::{GpuMode, Properties, RogPlatform, ThrottlePolicy};
use rog_platform::power::AsusPower; use rog_platform::power::AsusPower;
use zbus::export::futures_util::lock::Mutex; use zbus::export::futures_util::lock::Mutex;
@@ -96,7 +95,6 @@ impl CtrlPlatform {
config_path: &Path, config_path: &Path,
signal_context: SignalEmitter<'static>, signal_context: SignalEmitter<'static>,
) -> Result<Self, RogError> { ) -> Result<Self, RogError> {
// let attrs = FirmwareAttributes::new();
let platform = RogPlatform::new()?; let platform = RogPlatform::new()?;
let power = AsusPower::new()?; let power = AsusPower::new()?;

View File

@@ -15,7 +15,7 @@ pub mod notify;
pub mod tray; pub mod tray;
pub mod types; pub mod types;
pub mod ui; pub mod ui;
pub mod zbus; pub mod zbus_proxies;
pub const VERSION: &str = env!("CARGO_PKG_VERSION"); pub const VERSION: &str = env!("CARGO_PKG_VERSION");
pub const APP_ICON_PATH: &str = "/usr/share/icons/hicolor/512x512/apps/rog-control-center.png"; pub const APP_ICON_PATH: &str = "/usr/share/icons/hicolor/512x512/apps/rog-control-center.png";

View File

@@ -16,7 +16,7 @@ use rog_control_center::notify::start_notifications;
use rog_control_center::slint::ComponentHandle; use rog_control_center::slint::ComponentHandle;
use rog_control_center::tray::init_tray; use rog_control_center::tray::init_tray;
use rog_control_center::ui::setup_window; use rog_control_center::ui::setup_window;
use rog_control_center::zbus::{ use rog_control_center::zbus_proxies::{
AppState, ROGCCZbus, ROGCCZbusProxyBlocking, ZBUS_IFACE, ZBUS_PATH, AppState, ROGCCZbus, ROGCCZbusProxyBlocking, ZBUS_IFACE, ZBUS_PATH,
}; };
use rog_control_center::{print_versions, MainWindow}; use rog_control_center::{print_versions, MainWindow};
@@ -153,6 +153,8 @@ async fn main() -> Result<()> {
state = *lock; state = *lock;
} }
// This sleep is required to give the event loop time to react
sleep(Duration::from_millis(300));
if state == AppState::MainWindowShouldOpen { if state == AppState::MainWindowShouldOpen {
if let Ok(mut lock) = app_state.lock() { if let Ok(mut lock) = app_state.lock() {
*lock = AppState::MainWindowOpen; *lock = AppState::MainWindowOpen;
@@ -197,7 +199,6 @@ async fn main() -> Result<()> {
} }
} }
} }
sleep(Duration::from_millis(300));
} }
}); });

View File

@@ -14,7 +14,7 @@ use supergfxctl::zbus_proxy::DaemonProxy as GfxProxy;
use versions::Versioning; use versions::Versioning;
use crate::config::Config; use crate::config::Config;
use crate::zbus::{AppState, ROGCCZbusProxyBlocking}; use crate::zbus_proxies::{AppState, ROGCCZbusProxyBlocking};
const TRAY_LABEL: &str = "ROG Control Center"; const TRAY_LABEL: &str = "ROG Control Center";
const TRAY_ICON_PATH: &str = "/usr/share/icons/hicolor/512x512/apps/"; const TRAY_ICON_PATH: &str = "/usr/share/icons/hicolor/512x512/apps/";

View File

@@ -16,21 +16,6 @@ use crate::ui::setup_fans::setup_fan_curve_page;
use crate::ui::setup_system::{setup_system_page, setup_system_page_callbacks}; use crate::ui::setup_system::{setup_system_page, setup_system_page_callbacks};
use crate::{AppSettingsPageData, MainWindow}; use crate::{AppSettingsPageData, MainWindow};
// This macro expects are consistent naming between proxy calls and slint
// globals
#[macro_export]
macro_rules! set_ui_props_async {
($ui:ident, $proxy:ident, $global:ident, $proxy_fn:ident) => {
if let Ok(value) = $proxy.$proxy_fn().await {
$ui.upgrade_in_event_loop(move |handle| {
concat_idents::concat_idents!(set = set_, $proxy_fn {
handle.global::<$global>().set(value.into());
});
}).ok();
}
};
}
// this macro sets up: // this macro sets up:
// - a link from UI callback -> dbus proxy property // - a link from UI callback -> dbus proxy property
// - a link from dbus property signal -> UI state // - a link from dbus property signal -> UI state

View File

@@ -1,40 +1,201 @@
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use rog_dbus::asus_armoury::AsusArmouryProxy;
use rog_dbus::zbus_platform::{PlatformProxy, PlatformProxyBlocking}; use rog_dbus::zbus_platform::{PlatformProxy, PlatformProxyBlocking};
use rog_platform::firmware_attributes::FirmwareAttribute;
use rog_platform::platform::Properties; use rog_platform::platform::Properties;
use slint::ComponentHandle; use slint::ComponentHandle;
use super::show_toast; use super::show_toast;
use crate::config::Config; use crate::config::Config;
use crate::{ use crate::zbus_proxies::find_iface_async;
set_ui_callbacks, set_ui_props_async, AvailableSystemProperties, MainWindow, SystemPageData, use crate::{set_ui_props_async, AttrMinMax, MainWindow, SystemPageData};
use concat_idents::concat_idents;
const MINMAX: AttrMinMax = AttrMinMax {
min: 0,
max: 0,
val: -1.0,
}; };
pub fn setup_system_page(ui: &MainWindow, _config: Arc<Mutex<Config>>) { pub fn setup_system_page(ui: &MainWindow, _config: Arc<Mutex<Config>>) {
let conn = zbus::blocking::Connection::system().unwrap(); let conn = zbus::blocking::Connection::system().unwrap();
let platform = PlatformProxyBlocking::new(&conn).unwrap(); let platform = PlatformProxyBlocking::new(&conn).unwrap();
// let armoury_attrs = find_iface::<AsusArmouryProxyBlocking>("xyz.ljones.AsusArmoury").unwrap();
// Null everything before the setup step
ui.global::<SystemPageData>()
.set_charge_control_end_threshold(-1.0);
ui.global::<SystemPageData>()
.set_throttle_thermal_policy(-1);
ui.global::<SystemPageData>().set_panel_overdrive(-1);
ui.global::<SystemPageData>().set_boot_sound(-1);
ui.global::<SystemPageData>().set_mini_led_mode(-1);
ui.global::<SystemPageData>().set_ppt_pl1_spl(MINMAX);
ui.global::<SystemPageData>().set_ppt_pl2_sppt(MINMAX);
ui.global::<SystemPageData>().set_ppt_fppt(MINMAX);
ui.global::<SystemPageData>().set_ppt_apu_sppt(MINMAX);
ui.global::<SystemPageData>().set_ppt_platform_sppt(MINMAX);
ui.global::<SystemPageData>().set_nv_dynamic_boost(MINMAX);
ui.global::<SystemPageData>().set_nv_temp_target(MINMAX);
let sys_props = platform.supported_properties().unwrap(); let sys_props = platform.supported_properties().unwrap();
log::debug!("Available system properties: {sys_props:?}"); log::debug!("Available system properties: {sys_props:?}");
let props = AvailableSystemProperties { if sys_props.contains(&Properties::ChargeControlEndThreshold) {
ac_command: true, ui.global::<SystemPageData>()
bat_command: true, .set_charge_control_end_threshold(60.0);
charge_control_end_threshold: sys_props.contains(&Properties::ChargeControlEndThreshold), }
disable_nvidia_powerd_on_battery: true, }
mini_led_mode: sys_props.contains(&Properties::MiniLedMode),
nv_dynamic_boost: sys_props.contains(&Properties::NvDynamicBoost),
nv_temp_target: sys_props.contains(&Properties::NvTempTarget),
panel_od: sys_props.contains(&Properties::PanelOd),
boot_sound: sys_props.contains(&Properties::PostAnimationSound),
ppt_apu_sppt: sys_props.contains(&Properties::PptApuSppt),
ppt_fppt: sys_props.contains(&Properties::PptFppt),
ppt_pl1_spl: sys_props.contains(&Properties::PptPl1Spl),
ppt_pl2_sppt: sys_props.contains(&Properties::PptPl2Sppt),
ppt_platform_sppt: sys_props.contains(&Properties::PptPlatformSppt),
throttle_thermal_policy: sys_props.contains(&Properties::ThrottlePolicy),
};
ui.global::<SystemPageData>().set_available(props); macro_rules! convert_value {
(bool, $value:expr) => {
$value == 1
};
(i32, $value:expr) => {
$value as i32
};
(f32, $value:expr) => {
$value as f32
};
}
macro_rules! convert_to_dbus {
(bool, $value:expr) => {
if $value {
1
} else {
0
}
};
(i32, $value:expr) => {
$value as i32
};
(f32, $value:expr) => {
$value as i32
};
}
macro_rules! init_property {
($property:ident, $handle:expr, $value:expr, $type:tt) => {{
concat_idents!(setter = set_, $property {
$handle.global::<SystemPageData>().setter(convert_value!($type, $value));
});
}};
}
// For initial setup of min/max/val values
macro_rules! init_minmax_property {
($property:ident, $handle:expr, $attr:expr) => {
let proxy_copy = $attr.clone();
let handle_copy = $handle.as_weak();
tokio::spawn(async move {
let min = proxy_copy.min_value().await.unwrap();
let max = proxy_copy.max_value().await.unwrap();
let val = proxy_copy.current_value().await.unwrap() as f32;
handle_copy
.upgrade_in_event_loop(move |handle| {
concat_idents!(setter = set_, $property {
handle
.global::<SystemPageData>()
.setter(AttrMinMax { min, max, val });
});
})
.ok();
});
};
}
// For handling callbacks from UI value changes
macro_rules! setup_callback {
($property:ident, $handle:expr, $attr:expr, $type:tt) => {
let handle_copy = $handle.as_weak();
let proxy_copy = $attr.clone();
concat_idents!(on_callback = on_cb_, $property {
$handle
.global::<SystemPageData>()
.on_callback(move |v| {
let handle_copy = handle_copy.clone();
let proxy_copy = proxy_copy.clone();
tokio::spawn(async move {
show_toast(
format!("{} successfully set to {}", stringify!($property), v).into(),
format!("Setting {} failed", stringify!($property)).into(),
handle_copy,
proxy_copy.set_current_value(convert_to_dbus!($type, v)).await,
);
});
});
});
};
}
macro_rules! setup_external {
($property:ident, $type:tt, $handle:expr, $attr:expr, $value:expr) => {{
// EXTERNAL CHANGES
let handle_copy = $handle.as_weak();
let proxy_copy = $attr.clone();
concat_idents!(setter = set_, $property {
tokio::spawn(async move {
let mut x = proxy_copy.receive_current_value_changed().await;
use zbus::export::futures_util::StreamExt;
while let Some(e) = x.next().await {
if let Ok(out) = e.get().await {
dbg!(out);
handle_copy
.upgrade_in_event_loop(move |handle| {
handle
.global::<SystemPageData>()
.setter(convert_value!($type, out));
})
.ok();
}
}
});
});
}};
}
// For handling external value changes
macro_rules! setup_minmax_external {
($property:ident, $handle:expr, $attr:expr) => {
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 zbus::export::futures_util::StreamExt;
while let Some(e) = x.next().await {
if let Ok(out) = e.get().await {
concat_idents!(getter = get_, $property {
handle_copy
.upgrade_in_event_loop(move |handle| {
let mut tmp: AttrMinMax =
handle.global::<SystemPageData>().getter();
tmp.val = out as f32;
concat_idents!(setter = set_, $property {
handle.global::<SystemPageData>().setter(tmp);
});
})
.ok();
});
}
}
});
};
}
// This macro expects are consistent naming between proxy calls and slint
// globals
#[macro_export]
macro_rules! set_ui_props_async {
($ui:ident, $proxy:ident, $global:ident, $proxy_fn:ident) => {
if let Ok(value) = $proxy.$proxy_fn().await {
$ui.upgrade_in_event_loop(move |handle| {
concat_idents::concat_idents!(set = set_, $proxy_fn {
handle.global::<$global>().set(value.into());
});
}).ok();
}
};
} }
pub fn setup_system_page_callbacks(ui: &MainWindow, _states: Arc<Mutex<Config>>) { pub fn setup_system_page_callbacks(ui: &MainWindow, _states: Arc<Mutex<Config>>) {
@@ -46,6 +207,9 @@ pub fn setup_system_page_callbacks(ui: &MainWindow, _states: Arc<Mutex<Config>>)
// Create the connections/proxies here to prevent future delays in process // Create the connections/proxies here to prevent future delays in process
let conn = zbus::Connection::system().await.unwrap(); let conn = zbus::Connection::system().await.unwrap();
let platform = PlatformProxy::new(&conn).await.unwrap(); let platform = PlatformProxy::new(&conn).await.unwrap();
let armoury_attrs = find_iface_async::<AsusArmouryProxy>("xyz.ljones.AsusArmoury")
.await
.unwrap();
set_ui_props_async!( set_ui_props_async!(
handle, handle,
@@ -74,169 +238,78 @@ pub fn setup_system_page_callbacks(ui: &MainWindow, _states: Arc<Mutex<Config>>)
change_throttle_policy_on_ac change_throttle_policy_on_ac
); );
set_ui_props_async!(handle, platform, SystemPageData, panel_od); for attr in armoury_attrs {
set_ui_props_async!(handle, platform, SystemPageData, boot_sound); if let Ok(value) = attr.current_value().await {
set_ui_props_async!(handle, platform, SystemPageData, mini_led_mode); let name = attr.name().await.unwrap();
set_ui_props_async!(handle, platform, SystemPageData, ppt_pl1_spl); handle
set_ui_props_async!(handle, platform, SystemPageData, ppt_pl2_sppt); .upgrade_in_event_loop(move |handle| match name {
set_ui_props_async!(handle, platform, SystemPageData, ppt_fppt); FirmwareAttribute::ApuMem => {}
set_ui_props_async!(handle, platform, SystemPageData, ppt_apu_sppt); FirmwareAttribute::CoresPerformance => {}
set_ui_props_async!(handle, platform, SystemPageData, ppt_platform_sppt); FirmwareAttribute::CoresEfficiency => {}
set_ui_props_async!(handle, platform, SystemPageData, nv_dynamic_boost); FirmwareAttribute::PptPl1Spl => {
set_ui_props_async!(handle, platform, SystemPageData, nv_temp_target); init_minmax_property!(ppt_pl1_spl, handle, attr);
setup_callback!(ppt_pl1_spl, handle, attr, i32);
let sys_props = platform.supported_properties().await.unwrap(); setup_minmax_external!(ppt_pl1_spl, handle, attr);
log::debug!("Available system properties: {sys_props:?}"); }
let props = AvailableSystemProperties { FirmwareAttribute::PptPl2Sppt => {
ac_command: true, init_minmax_property!(ppt_pl2_sppt, handle, attr);
bat_command: true, setup_callback!(ppt_pl2_sppt, handle, attr, i32);
charge_control_end_threshold: sys_props setup_minmax_external!(ppt_pl2_sppt, handle, attr);
.contains(&Properties::ChargeControlEndThreshold), }
disable_nvidia_powerd_on_battery: true, FirmwareAttribute::PptApuSppt => {
mini_led_mode: sys_props.contains(&Properties::MiniLedMode), init_minmax_property!(ppt_apu_sppt, handle, attr);
nv_dynamic_boost: sys_props.contains(&Properties::NvDynamicBoost), setup_callback!(ppt_apu_sppt, handle, attr, i32);
nv_temp_target: sys_props.contains(&Properties::NvTempTarget), setup_minmax_external!(ppt_apu_sppt, handle, attr);
panel_od: sys_props.contains(&Properties::PanelOd), }
boot_sound: sys_props.contains(&Properties::PostAnimationSound), FirmwareAttribute::PptPlatformSppt => {
ppt_apu_sppt: sys_props.contains(&Properties::PptApuSppt), init_minmax_property!(ppt_platform_sppt, handle, attr);
ppt_fppt: sys_props.contains(&Properties::PptFppt), setup_callback!(ppt_platform_sppt, handle, attr, i32);
ppt_pl1_spl: sys_props.contains(&Properties::PptPl1Spl), setup_minmax_external!(ppt_platform_sppt, handle, attr);
ppt_pl2_sppt: sys_props.contains(&Properties::PptPl2Sppt), }
ppt_platform_sppt: sys_props.contains(&Properties::PptPlatformSppt), FirmwareAttribute::PptFppt => {
throttle_thermal_policy: sys_props.contains(&Properties::ThrottlePolicy), init_minmax_property!(ppt_fppt, handle, attr);
}; setup_callback!(ppt_fppt, handle, attr, i32);
setup_minmax_external!(ppt_fppt, handle, attr);
// TODO: move the fail/sucess messages to slint }
handle FirmwareAttribute::NvDynamicBoost => {
.upgrade_in_event_loop(move |handle| { init_minmax_property!(nv_dynamic_boost, handle, attr);
handle.global::<SystemPageData>().set_available(props); setup_callback!(nv_dynamic_boost, handle, attr, i32);
setup_minmax_external!(nv_dynamic_boost, handle, attr);
set_ui_callbacks!(handle, }
SystemPageData(as f32), FirmwareAttribute::NvTempTarget => {
platform.charge_control_end_threshold(as u8), init_minmax_property!(nv_temp_target, handle, attr);
"Charge limit successfully set to {}", setup_callback!(nv_temp_target, handle, attr, i32);
"Setting Charge limit failed" setup_minmax_external!(nv_temp_target, handle, attr);
); }
set_ui_callbacks!( FirmwareAttribute::DgpuBaseTgp => {}
handle, FirmwareAttribute::DgpuTgp => {}
SystemPageData(), FirmwareAttribute::ChargeMode => {}
platform.panel_od(), FirmwareAttribute::BootSound => {
"Panel OverDrive successfully set to {}", init_property!(boot_sound, handle, value, i32);
"Setting Panel OverDrive failed" setup_callback!(boot_sound, handle, attr, i32);
); setup_external!(boot_sound, i32, handle, attr, value)
set_ui_callbacks!( }
handle, FirmwareAttribute::McuPowersave => {}
SystemPageData(), FirmwareAttribute::PanelOverdrive => {
platform.boot_sound(), init_property!(panel_overdrive, handle, value, i32);
"POST Animation sound successfully set to {}", setup_callback!(panel_overdrive, handle, attr, i32);
"Setting POST Animation sound failed" setup_external!(panel_overdrive, i32, handle, attr, value)
); }
set_ui_callbacks!( FirmwareAttribute::PanelHdMode => {}
handle, FirmwareAttribute::EgpuConnected => {}
SystemPageData(), FirmwareAttribute::EgpuEnable => {}
platform.mini_led_mode(), FirmwareAttribute::DgpuDisable => {}
"MiniLED mode successfully set to {}", FirmwareAttribute::GpuMuxMode => {}
"Setting MiniLED mode failed" FirmwareAttribute::MiniLedMode => {
); init_property!(mini_led_mode, handle, value, i32);
set_ui_callbacks!(handle, setup_callback!(mini_led_mode, handle, attr, i32);
SystemPageData(as i32), setup_external!(mini_led_mode, i32, handle, attr, value)
platform.throttle_thermal_policy(.into()), }
"Throttle policy set to {}", FirmwareAttribute::PendingReboot => {}
"Setting Throttle policy failed" FirmwareAttribute::None => {}
); })
.ok();
set_ui_callbacks!(handle, }
SystemPageData(as i32), }
platform.throttle_balanced_epp(.into()),
"Throttle policy EPP set to {}",
"Setting Throttle policy EPP failed"
);
set_ui_callbacks!(handle,
SystemPageData(as i32),
platform.throttle_performance_epp(.into()),
"Throttle policy EPP set to {}",
"Setting Throttle policy EPP failed"
);
set_ui_callbacks!(handle,
SystemPageData(as i32),
platform.throttle_quiet_epp(.into()),
"Throttle policy EPP set to {}",
"Setting Throttle policy EPP failed"
);
set_ui_callbacks!(
handle,
SystemPageData(),
platform.throttle_policy_linked_epp(),
"Throttle policy linked to EPP: {}",
"Setting Throttle policy linked to EPP failed"
);
set_ui_callbacks!(handle,
SystemPageData(as i32),
platform.throttle_policy_on_ac(.into()),
"Throttle policy on AC set to {}",
"Setting Throttle policy on AC failed"
);
set_ui_callbacks!(handle,
SystemPageData(as bool),
platform.change_throttle_policy_on_ac(.into()),
"Throttle policy on AC enabled: {}",
"Setting Throttle policy on AC failed"
);
set_ui_callbacks!(handle,
SystemPageData(as i32),
platform.throttle_policy_on_battery(.into()),
"Throttle policy on abttery set to {}",
"Setting Throttle policy on battery failed"
);
set_ui_callbacks!(handle,
SystemPageData(as bool),
platform.change_throttle_policy_on_battery(.into()),
"Throttle policy on battery enabled: {}",
"Setting Throttle policy on AC failed"
);
set_ui_callbacks!(handle,
SystemPageData(as f32),
platform.ppt_pl1_spl(as u8),
"ppt_pl1_spl successfully set to {}",
"Setting ppt_pl1_spl failed"
);
set_ui_callbacks!(handle,
SystemPageData(as f32),
platform.ppt_pl2_sppt(as u8),
"ppt_pl2_sppt successfully set to {}",
"Setting ppt_pl2_sppt failed"
);
set_ui_callbacks!(handle,
SystemPageData(as f32),
platform.ppt_fppt(as u8),
"ppt_fppt successfully set to {}",
"Setting ppt_fppt failed"
);
set_ui_callbacks!(handle,
SystemPageData(as f32),
platform.ppt_apu_sppt(as u8),
"ppt_apu_sppt successfully set to {}",
"Setting ppt_apu_sppt failed"
);
set_ui_callbacks!(handle,
SystemPageData(as f32),
platform.ppt_platform_sppt(as u8),
"ppt_platform_sppt successfully set to {}",
"Setting ppt_platform_sppt failed"
);
set_ui_callbacks!(handle,
SystemPageData(as f32),
platform.nv_temp_target(as u8),
"nv_temp_target successfully set to {}",
"Setting nv_temp_target failed"
);
set_ui_callbacks!(handle,
SystemPageData(as f32),
platform.nv_dynamic_boost(as u8),
"nv_dynamic_boost successfully set to {}",
"Setting nv_dynamic_boost failed"
);
})
.unwrap();
}); });
} }

View File

@@ -1,68 +0,0 @@
use std::sync::{Arc, Mutex};
use zbus::zvariant::{OwnedValue, Type, Value};
use zbus::{interface, proxy};
#[derive(Debug, Copy, Clone, PartialEq, Eq, Type, Value, OwnedValue)]
#[zvariant(signature = "u")]
pub enum AppState {
MainWindowOpen = 0,
/// If the app is running, open the main window
MainWindowShouldOpen = 1,
MainWindowClosed = 2,
StartingUp = 3,
QuitApp = 4,
LockFailed = 5,
}
pub struct ROGCCZbus {
state: Arc<Mutex<AppState>>,
}
impl ROGCCZbus {
pub fn new() -> Self {
Self {
state: Arc::new(Mutex::new(AppState::StartingUp)),
}
}
pub fn clone_state(&self) -> Arc<Mutex<AppState>> {
self.state.clone()
}
}
pub const ZBUS_PATH: &str = "/xyz/ljones/rogcc";
pub const ZBUS_IFACE: &str = "xyz.ljones.rogcc";
#[interface(name = "xyz.ljones.rogcc")]
impl ROGCCZbus {
/// Return the device type for this Aura keyboard
#[zbus(property)]
async fn state(&self) -> AppState {
if let Ok(lock) = self.state.try_lock() {
return *lock;
}
AppState::LockFailed
}
#[zbus(property)]
async fn set_state(&self, state: AppState) {
if let Ok(mut lock) = self.state.try_lock() {
*lock = state;
}
}
}
#[proxy(
interface = "xyz.ljones.rogcc",
default_service = "xyz.ljones.rogcc",
default_path = "/xyz/ljones/rogcc"
)]
pub trait ROGCCZbus {
/// EnableDisplay property
#[zbus(property)]
fn state(&self) -> zbus::Result<AppState>;
#[zbus(property)]
fn set_state(&self, state: AppState) -> zbus::Result<()>;
}

View File

@@ -0,0 +1,149 @@
use std::sync::{Arc, Mutex};
use zbus::blocking::proxy::ProxyImpl;
use zbus::blocking::{fdo, Connection};
use zbus::zvariant::{OwnedValue, Type, Value};
use zbus::{interface, proxy};
#[derive(Debug, Copy, Clone, PartialEq, Eq, Type, Value, OwnedValue)]
#[zvariant(signature = "u")]
pub enum AppState {
MainWindowOpen = 0,
/// If the app is running, open the main window
MainWindowShouldOpen = 1,
MainWindowClosed = 2,
StartingUp = 3,
QuitApp = 4,
LockFailed = 5,
}
pub struct ROGCCZbus {
state: Arc<Mutex<AppState>>,
}
impl ROGCCZbus {
pub fn new() -> Self {
Self {
state: Arc::new(Mutex::new(AppState::StartingUp)),
}
}
pub fn clone_state(&self) -> Arc<Mutex<AppState>> {
self.state.clone()
}
}
pub const ZBUS_PATH: &str = "/xyz/ljones/rogcc";
pub const ZBUS_IFACE: &str = "xyz.ljones.rogcc";
#[interface(name = "xyz.ljones.rogcc")]
impl ROGCCZbus {
/// Return the device type for this Aura keyboard
#[zbus(property)]
async fn state(&self) -> AppState {
if let Ok(lock) = self.state.try_lock() {
return *lock;
}
AppState::LockFailed
}
#[zbus(property)]
async fn set_state(&self, state: AppState) {
if let Ok(mut lock) = self.state.try_lock() {
*lock = state;
}
}
}
#[proxy(
interface = "xyz.ljones.rogcc",
default_service = "xyz.ljones.rogcc",
default_path = "/xyz/ljones/rogcc"
)]
pub trait ROGCCZbus {
/// EnableDisplay property
#[zbus(property)]
fn state(&self) -> zbus::Result<AppState>;
#[zbus(property)]
fn set_state(&self, state: AppState) -> zbus::Result<()>;
}
pub fn find_iface<T>(iface_name: &str) -> Result<Vec<T>, Box<dyn std::error::Error>>
where
T: ProxyImpl<'static> + From<zbus::Proxy<'static>>,
{
let conn = Connection::system().unwrap();
let f = fdo::ObjectManagerProxy::new(&conn, "xyz.ljones.Asusd", "/").unwrap();
let interfaces = f.get_managed_objects().unwrap();
let mut paths = Vec::new();
for v in interfaces.iter() {
// let o: Vec<zbus::names::OwnedInterfaceName> = v.1.keys().map(|e|
// e.to_owned()).collect(); println!("{}, {:?}", v.0, o);
for k in v.1.keys() {
if k.as_str() == iface_name {
// println!("Found {iface_name} device at {}, {}", v.0, k);
paths.push(v.0.clone());
}
}
}
if paths.len() > 1 {
println!("Multiple asusd interfaces devices found");
}
if !paths.is_empty() {
let mut ctrl = Vec::new();
paths.sort_by(|a, b| a.cmp(&b));
for path in paths {
ctrl.push(
T::builder(&conn)
.path(path.clone())?
.destination("xyz.ljones.Asusd")?
.build()?,
);
}
return Ok(ctrl);
}
Err("No Aura interface".into())
}
pub async fn find_iface_async<T>(iface_name: &str) -> Result<Vec<T>, Box<dyn std::error::Error>>
where
T: zbus::proxy::ProxyImpl<'static> + From<zbus::Proxy<'static>>,
{
let conn = zbus::Connection::system().await.unwrap();
let f = zbus::fdo::ObjectManagerProxy::new(&conn, "xyz.ljones.Asusd", "/")
.await
.unwrap();
let interfaces = f.get_managed_objects().await.unwrap();
let mut paths = Vec::new();
for v in interfaces.iter() {
// let o: Vec<zbus::names::OwnedInterfaceName> = v.1.keys().map(|e|
// e.to_owned()).collect(); println!("{}, {:?}", v.0, o);
for k in v.1.keys() {
if k.as_str() == iface_name {
// println!("Found {iface_name} device at {}, {}", v.0, k);
paths.push(v.0.clone());
}
}
}
if paths.len() > 1 {
println!("Multiple asusd interfaces devices found");
}
if !paths.is_empty() {
let mut ctrl = Vec::new();
paths.sort_by(|a, b| a.cmp(&b));
for path in paths {
ctrl.push(
T::builder(&conn)
.path(path.clone())?
.destination("xyz.ljones.Asusd")?
.build()
.await?,
);
}
return Ok(ctrl);
}
Err("No Aura interface".into())
}

View File

@@ -2,7 +2,7 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2024-12-28 22:48+0000\n" "POT-Creation-Date: 2024-12-30 08:46+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -12,157 +12,157 @@ msgstr ""
"Language: \n" "Language: \n"
"Plural-Forms: nplurals=1; plural=0;\n" "Plural-Forms: nplurals=1; plural=0;\n"
#: rog-control-center/ui/pages/system.slint:26 #: rog-control-center/ui/pages/system.slint:8
msgctxt "SystemPageData" msgctxt "SystemPageData"
msgid "Balanced" msgid "Balanced"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:26 rog-control-center/ui/pages/system.slint:30 #: rog-control-center/ui/pages/system.slint:8 rog-control-center/ui/pages/system.slint:12
msgctxt "SystemPageData" msgctxt "SystemPageData"
msgid "Performance" msgid "Performance"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:26 #: rog-control-center/ui/pages/system.slint:8
msgctxt "SystemPageData" msgctxt "SystemPageData"
msgid "Quiet" msgid "Quiet"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:29 #: rog-control-center/ui/pages/system.slint:11
msgctxt "SystemPageData" msgctxt "SystemPageData"
msgid "Default" msgid "Default"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:31 #: rog-control-center/ui/pages/system.slint:13
msgctxt "SystemPageData" msgctxt "SystemPageData"
msgid "BalancePerformance" msgid "BalancePerformance"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:32 #: rog-control-center/ui/pages/system.slint:14
msgctxt "SystemPageData" msgctxt "SystemPageData"
msgid "BalancePower" msgid "BalancePower"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:33 #: rog-control-center/ui/pages/system.slint:15
msgctxt "SystemPageData" msgctxt "SystemPageData"
msgid "Power" msgid "Power"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:110 #: rog-control-center/ui/pages/system.slint:76
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "Base system settings" msgid "Base system settings"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:115 #: rog-control-center/ui/pages/system.slint:81
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "Charge limit" msgid "Charge limit"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:127 #: rog-control-center/ui/pages/system.slint:93
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "Throttle Policy" msgid "Throttle Policy"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:137 #: rog-control-center/ui/pages/system.slint:103
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "Advanced" msgid "Advanced"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:149 #: rog-control-center/ui/pages/system.slint:115
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "Panel Overdrive" msgid "Panel Overdrive"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:157 #: rog-control-center/ui/pages/system.slint:123
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "MiniLED Mode" msgid "MiniLED Mode"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:165 #: rog-control-center/ui/pages/system.slint:131
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "POST boot sound" msgid "POST boot sound"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:183 #: rog-control-center/ui/pages/system.slint:149
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "System performance settings" msgid "System performance settings"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:188 #: rog-control-center/ui/pages/system.slint:154
msgctxt "ppt_pl1_spl" msgctxt "ppt_pl1_spl"
msgid "PL1, sustained power limit" msgid "PL1, sustained power limit"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:198 #: rog-control-center/ui/pages/system.slint:164
msgctxt "ppt_pl2_sppt" msgctxt "ppt_pl2_sppt"
msgid "PL2, turbo power limit" msgid "PL2, turbo power limit"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:208 #: rog-control-center/ui/pages/system.slint:174
msgctxt "ppt_fppt" msgctxt "ppt_fppt"
msgid "FPPT, Fast Power Limit" msgid "FPPT, Fast Power Limit"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:218 #: rog-control-center/ui/pages/system.slint:184
msgctxt "ppt_apu_sppt" msgctxt "ppt_apu_sppt"
msgid "SPPT, APU slow power limit" msgid "SPPT, APU slow power limit"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:228 #: rog-control-center/ui/pages/system.slint:194
msgctxt "ppt_platform_sppt" msgctxt "ppt_platform_sppt"
msgid "Slow package power tracking limit" msgid "Slow package power tracking limit"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:238 #: rog-control-center/ui/pages/system.slint:204
msgctxt "nv_dynamic_boost" msgctxt "nv_dynamic_boost"
msgid "dGPU boost overclock" msgid "dGPU boost overclock"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:248 #: rog-control-center/ui/pages/system.slint:214
msgctxt "nv_temp_target" msgctxt "nv_temp_target"
msgid "dGPU temperature max" msgid "dGPU temperature max"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:294 #: rog-control-center/ui/pages/system.slint:260
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "Energy Performance Preference linked to Throttle Policy" msgid "Energy Performance Preference linked to Throttle Policy"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:298 #: rog-control-center/ui/pages/system.slint:264
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "Change EPP based on Throttle Policy" msgid "Change EPP based on Throttle Policy"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:306 #: rog-control-center/ui/pages/system.slint:272
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "EPP for Balanced Policy" msgid "EPP for Balanced Policy"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:316 #: rog-control-center/ui/pages/system.slint:282
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "EPP for Performance Policy" msgid "EPP for Performance Policy"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:326 #: rog-control-center/ui/pages/system.slint:292
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "EPP for Quiet Policy" msgid "EPP for Quiet Policy"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:344 #: rog-control-center/ui/pages/system.slint:310
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "Throttle Policy for power state" msgid "Throttle Policy for power state"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:350 #: rog-control-center/ui/pages/system.slint:316
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "Throttle Policy on Battery" msgid "Throttle Policy on Battery"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:360 rog-control-center/ui/pages/system.slint:381 #: rog-control-center/ui/pages/system.slint:326 rog-control-center/ui/pages/system.slint:347
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "Enabled" msgid "Enabled"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:371 #: rog-control-center/ui/pages/system.slint:337
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "Throttle Policy on AC" msgid "Throttle Policy on AC"
msgstr "" msgstr ""

View File

@@ -1,6 +1,6 @@
import { Palette, Button, VerticalBox } from "std-widgets.slint"; import { Palette, Button, VerticalBox } from "std-widgets.slint";
import { AppSize } from "globals.slint"; import { AppSize } from "globals.slint";
import { PageSystem, AvailableSystemProperties, SystemPageData } from "pages/system.slint"; import { PageSystem, SystemPageData, AttrMinMax } from "pages/system.slint";
import { SideBar } from "widgets/sidebar.slint"; import { SideBar } from "widgets/sidebar.slint";
import { PageAbout } from "pages/about.slint"; import { PageAbout } from "pages/about.slint";
import { PageFans } from "pages/fans.slint"; import { PageFans } from "pages/fans.slint";
@@ -15,7 +15,7 @@ import { AuraPageData, AuraDevType, LaptopAuraPower, AuraPowerState, PowerZones,
export { AuraPageData, AuraDevType, LaptopAuraPower, AuraPowerState, PowerZones, AuraEffect } export { AuraPageData, AuraDevType, LaptopAuraPower, AuraPowerState, PowerZones, AuraEffect }
import { PageAppSettings, AppSettingsPageData } from "pages/app_settings.slint"; import { PageAppSettings, AppSettingsPageData } from "pages/app_settings.slint";
export { AppSize, AvailableSystemProperties, SystemPageData, AnimePageData, AppSettingsPageData } export { AppSize, AttrMinMax, SystemPageData, AnimePageData, AppSettingsPageData }
export component MainWindow inherits Window { export component MainWindow inherits Window {
title: "ROG Control"; title: "ROG Control";
@@ -134,7 +134,8 @@ export component MainWindow inherits Window {
y: 0px; y: 0px;
width: root.width; width: root.width;
height: 32px; height: 32px;
opacity: 0.8; opacity: 1.0;
background: Colors.grey;
TouchArea { TouchArea {
height: 100%; height: 100%;
width: 100%; width: 100%;

View File

@@ -1,30 +1,23 @@
import { SystemSlider, SystemDropdown, SystemToggle } from "../widgets/common.slint"; 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} from "std-widgets.slint";
export struct AvailableSystemProperties { export struct AttrMinMax {
charge_control_end_threshold: bool, min: int,
panel_od: bool, max: int,
boot_sound: bool, val: float,
mini_led_mode: bool, }
disable_nvidia_powerd_on_battery: bool,
ac_command: bool, export struct AttrPossible {
bat_command: bool, range: [int],
throttle_thermal_policy: bool, val: int,
ppt_pl1_spl: bool,
ppt_pl2_sppt: bool,
ppt_fppt: bool,
ppt_apu_sppt: bool,
ppt_platform_sppt: bool,
nv_dynamic_boost: bool,
nv_temp_target: bool,
} }
export global SystemPageData { export global SystemPageData {
in-out property <float> charge_control_end_threshold: 30; in-out property <float> charge_control_end_threshold: 30;
callback set_charge_control_end_threshold(/* charge limit */ int); callback cb_charge_control_end_threshold(/* charge limit */ int);
in-out property <int> throttle_thermal_policy: 0; in-out property <int> throttle_thermal_policy: 0;
in-out property <[string]> throttle_policy_choices: [@tr("Balanced"), @tr("Performance"), @tr("Quiet")]; in-out property <[string]> throttle_policy_choices: [@tr("Balanced"), @tr("Performance"), @tr("Quiet")];
callback set_throttle_thermal_policy(int); callback cb_throttle_thermal_policy(int);
in-out property <[string]> energy_performance_choices: [ in-out property <[string]> energy_performance_choices: [
@tr("Default"), @tr("Default"),
@tr("Performance"), @tr("Performance"),
@@ -33,59 +26,78 @@ export global SystemPageData {
@tr("Power") @tr("Power")
]; ];
in-out property <int> throttle_balanced_epp: 0; in-out property <int> throttle_balanced_epp: 0;
callback set_throttle_balanced_epp(int); callback cb_throttle_balanced_epp(int);
in-out property <int> throttle_performance_epp: 0; in-out property <int> throttle_performance_epp: 0;
callback set_throttle_performance_epp(int); callback cb_throttle_performance_epp(int);
in-out property <int> throttle_quiet_epp: 0; in-out property <int> throttle_quiet_epp: 0;
callback set_throttle_quiet_epp(int); callback cb_throttle_quiet_epp(int);
// if the EPP should change with throttle // if the EPP should change with throttle
in-out property <bool> throttle_policy_linked_epp: true; in-out property <bool> throttle_policy_linked_epp: true;
callback set_throttle_policy_linked_epp(bool); callback cb_throttle_policy_linked_epp(bool);
in-out property <int> throttle_policy_on_ac: 0; in-out property <int> throttle_policy_on_ac: 0;
callback set_throttle_policy_on_ac(int); callback cb_throttle_policy_on_ac(int);
in-out property <bool> change_throttle_policy_on_ac: true; in-out property <bool> change_throttle_policy_on_ac: true;
callback set_change_throttle_policy_on_ac(bool); callback cb_change_throttle_policy_on_ac(bool);
in-out property <int> throttle_policy_on_battery: 0; in-out property <int> throttle_policy_on_battery: 0;
callback set_throttle_policy_on_battery(int); callback cb_throttle_policy_on_battery(int);
in-out property <bool> change_throttle_policy_on_battery: true; in-out property <bool> change_throttle_policy_on_battery: true;
callback set_change_throttle_policy_on_battery(bool); callback cb_change_throttle_policy_on_battery(bool);
in-out property <bool> panel_od; //
callback set_panel_od(bool); in-out property <int> panel_overdrive;
in-out property <bool> boot_sound; callback cb_panel_overdrive(int);
callback set_boot_sound(bool); in-out property <int> boot_sound;
in-out property <bool> mini_led_mode; callback cb_boot_sound(int);
callback set_mini_led_mode(bool); in-out property <int> mini_led_mode;
in-out property <float> ppt_pl1_spl: 5; callback cb_mini_led_mode(int);
callback set_ppt_pl1_spl(int);
in-out property <float> ppt_pl2_sppt: 5; in-out property <AttrMinMax> ppt_pl1_spl: {
callback set_ppt_pl2_sppt(int); min: 0,
in-out property <float> ppt_fppt: 5; max: 100,
callback set_ppt_fppt(int); val: 20,
in-out property <float> ppt_apu_sppt: 5;
callback set_ppt_apu_sppt(int);
in-out property <float> ppt_platform_sppt: 5;
callback set_ppt_platform_sppt(int);
in-out property <float> nv_dynamic_boost: 5;
callback set_nv_dynamic_boost(int);
in-out property <float> nv_temp_target: 75;
callback set_nv_temp_target(int);
in-out property <AvailableSystemProperties> available: {
charge_control_end_threshold: true,
panel_od: true,
boot_sound: true,
mini_led_mode: true,
disable_nvidia_powerd_on_battery: true,
ac_command: true,
bat_command: true,
throttle_thermal_policy: true,
ppt_pl1_spl: true,
ppt_pl2_sppt: true,
ppt_fppt: true,
ppt_apu_sppt: true,
ppt_platform_sppt: true,
nv_dynamic_boost: true,
nv_temp_target: true,
}; };
callback cb_ppt_pl1_spl(int);
in-out property <AttrMinMax> ppt_pl2_sppt: {
min: 0,
max: 100,
val: 20,
};
callback cb_ppt_pl2_sppt(int);
in-out property <AttrMinMax> ppt_fppt: {
min: 0,
max: 100,
val: 20,
};
callback cb_ppt_fppt(int);
in-out property <AttrMinMax> ppt_apu_sppt: {
min: 0,
max: 100,
val: 20,
};
callback cb_ppt_apu_sppt(int);
in-out property <AttrMinMax> ppt_platform_sppt: {
min: 0,
max: 100,
val: 20,
};
callback cb_ppt_platform_sppt(int);
in-out property <AttrMinMax> nv_dynamic_boost: {
min: 0,
max: 30,
val: 5,
};
callback cb_nv_dynamic_boost(int);
in-out property <AttrMinMax> nv_temp_target: {
min: 0,
max: 80,
val: 75,
};
callback cb_nv_temp_target(int);
} }
export component PageSystem inherits Rectangle { export component PageSystem inherits Rectangle {
@@ -107,21 +119,21 @@ export component PageSystem inherits Rectangle {
font-size: 18px; font-size: 18px;
color: Palette.control-foreground; color: Palette.control-foreground;
horizontal-alignment: TextHorizontalAlignment.center; horizontal-alignment: TextHorizontalAlignment.center;
text: @tr("Base system settings"); text: @tr("Power settings");
} }
} }
if SystemPageData.available.charge-control-end-threshold: SystemSlider { if SystemPageData.charge_control_end_threshold != -1: SystemSlider {
text: @tr("Charge limit"); text: @tr("Charge limit");
minimum: 20; minimum: 20;
maximum: 100; maximum: 100;
value <=> SystemPageData.charge_control_end_threshold; value <=> SystemPageData.charge_control_end_threshold;
released => { released => {
SystemPageData.set_charge_control_end_threshold(Math.round(SystemPageData.charge_control_end_threshold)) SystemPageData.cb_charge_control_end_threshold(Math.round(SystemPageData.charge_control_end_threshold))
} }
} }
if SystemPageData.available.throttle-thermal-policy: HorizontalLayout { if SystemPageData.throttle_thermal_policy != -1: HorizontalLayout {
spacing: 10px; spacing: 10px;
SystemDropdown { SystemDropdown {
text: @tr("Throttle Policy"); text: @tr("Throttle Policy");
@@ -129,7 +141,7 @@ export component PageSystem inherits Rectangle {
current_value: SystemPageData.throttle_policy_choices[SystemPageData.throttle_thermal_policy]; current_value: SystemPageData.throttle_policy_choices[SystemPageData.throttle_thermal_policy];
model <=> SystemPageData.throttle_policy_choices; model <=> SystemPageData.throttle_policy_choices;
selected => { selected => {
SystemPageData.set_throttle_thermal_policy(SystemPageData.throttle_thermal_policy) SystemPageData.cb_throttle_thermal_policy(SystemPageData.throttle_thermal_policy)
} }
} }
@@ -142,34 +154,6 @@ export component PageSystem inherits Rectangle {
} }
} }
HorizontalBox {
padding: 0px;
spacing: 10px;
if SystemPageData.available.panel-od: SystemToggle {
text: @tr("Panel Overdrive");
checked <=> SystemPageData.panel_od;
toggled => {
SystemPageData.set_panel_od(SystemPageData.panel_od)
}
}
if SystemPageData.available.mini-led-mode: SystemToggle {
text: @tr("MiniLED Mode");
checked <=> SystemPageData.mini_led_mode;
toggled => {
SystemPageData.set_mini_led_mode(SystemPageData.mini_led_mode)
}
}
if SystemPageData.available.boot-sound: SystemToggle {
text: @tr("POST boot sound");
checked <=> SystemPageData.boot_sound;
toggled => {
SystemPageData.set_boot_sound(SystemPageData.boot_sound)
}
}
}
Rectangle { Rectangle {
background: Palette.alternate-background; background: Palette.alternate-background;
border-color: Palette.accent-background; border-color: Palette.accent-background;
@@ -180,77 +164,112 @@ export component PageSystem inherits Rectangle {
font-size: 18px; font-size: 18px;
color: Palette.control-foreground; color: Palette.control-foreground;
horizontal-alignment: TextHorizontalAlignment.center; horizontal-alignment: TextHorizontalAlignment.center;
text: @tr("System performance settings"); text: @tr("Armoury settings");
} }
} }
if SystemPageData.available.ppt-pl1-spl: SystemSlider { HorizontalBox {
padding: 0px;
spacing: 10px;
if SystemPageData.panel_overdrive != -1: SystemToggleInt {
text: @tr("Panel Overdrive");
checked_int <=> SystemPageData.panel_overdrive;
toggled => {
SystemPageData.cb_panel_overdrive(SystemPageData.panel_overdrive)
}
}
if SystemPageData.mini_led_mode != -1: SystemToggleInt {
text: @tr("MiniLED Mode");
checked_int <=> SystemPageData.mini_led_mode;
toggled => {
SystemPageData.cb_mini_led_mode(SystemPageData.mini_led_mode)
}
}
if SystemPageData.boot_sound != -1: SystemToggleInt {
text: @tr("POST boot sound");
checked_int <=> SystemPageData.boot_sound;
toggled => {
SystemPageData.cb_boot_sound(SystemPageData.boot_sound)
}
}
}
if SystemPageData.ppt_pl1_spl.val != -1: SystemSlider {
text: @tr("ppt_pl1_spl" => "PL1, sustained power limit"); text: @tr("ppt_pl1_spl" => "PL1, sustained power limit");
minimum: 5; minimum: SystemPageData.ppt_pl1_spl.min;
maximum: 250; maximum: SystemPageData.ppt_pl1_spl.max;
value <=> SystemPageData.ppt_pl1_spl; value: SystemPageData.ppt_pl1_spl.val;
released => { released => {
SystemPageData.set_ppt_pl1_spl(Math.round(SystemPageData.ppt_pl1_spl)) SystemPageData.ppt_pl1_spl.val = self.value;
SystemPageData.cb_ppt_pl1_spl(Math.round(self.value))
} }
} }
if SystemPageData.available.ppt-pl2-sppt: SystemSlider { if SystemPageData.ppt_pl2_sppt.val != -1: SystemSlider {
text: @tr("ppt_pl2_sppt" => "PL2, turbo power limit"); text: @tr("ppt_pl2_sppt" => "PL2, turbo power limit");
minimum: 5; minimum: SystemPageData.ppt_pl2_sppt.min;
maximum: 250; maximum: SystemPageData.ppt_pl2_sppt.max;
value <=> SystemPageData.ppt_pl2_sppt; value: SystemPageData.ppt_pl2_sppt.val;
released => { released => {
SystemPageData.set_ppt_pl2_sppt(Math.round(SystemPageData.ppt_pl2_sppt)) SystemPageData.ppt_pl2_sppt.val = self.value;
SystemPageData.cb_ppt_pl2_sppt(Math.round(self.value))
} }
} }
if SystemPageData.available.ppt-fppt: SystemSlider { if SystemPageData.ppt_fppt.val != -1: SystemSlider {
text: @tr("ppt_fppt" => "FPPT, Fast Power Limit"); text: @tr("ppt_fppt" => "FPPT, Fast Power Limit");
minimum: 5; minimum: SystemPageData.ppt_fppt.min;
maximum: 250; maximum: SystemPageData.ppt_fppt.max;
value <=> SystemPageData.ppt_fppt; value: SystemPageData.ppt_fppt.val;
released => { released => {
SystemPageData.set_ppt_fppt(Math.round(SystemPageData.ppt_fppt)) SystemPageData.ppt_fppt.val = self.value;
SystemPageData.cb_ppt_fppt(Math.round(self.value))
} }
} }
if SystemPageData.available.ppt-apu-sppt: SystemSlider { if SystemPageData.ppt_apu_sppt.val != -1: SystemSlider {
text: @tr("ppt_apu_sppt" => "SPPT, APU slow power limit"); text: @tr("ppt_apu_sppt" => "SPPT, APU slow power limit");
minimum: 5; minimum: SystemPageData.ppt_apu_sppt.min;
maximum: 130; maximum: SystemPageData.ppt_apu_sppt.max;
value <=> SystemPageData.ppt_apu_sppt; value: SystemPageData.ppt_apu_sppt.val;
released => { released => {
SystemPageData.set_ppt_apu_sppt(Math.round(SystemPageData.ppt_apu_sppt)) SystemPageData.ppt_apu_sppt.val = self.value;
SystemPageData.cb_ppt_apu_sppt(Math.round(self.value))
} }
} }
if SystemPageData.available.ppt-platform-sppt: SystemSlider { if SystemPageData.ppt_platform_sppt.val != -1: SystemSlider {
text: @tr("ppt_platform_sppt" => "Slow package power tracking limit"); text: @tr("ppt_platform_sppt" => "Slow package power tracking limit");
maximum: 130; minimum: SystemPageData.ppt_platform_sppt.min;
minimum: 5; maximum: SystemPageData.ppt_platform_sppt.max;
value <=> SystemPageData.ppt_platform_sppt; value: SystemPageData.ppt_platform_sppt.val;
released => { released => {
SystemPageData.set_ppt_platform_sppt(Math.round(SystemPageData.ppt_platform_sppt)) SystemPageData.ppt_platform_sppt.val = self.value;
SystemPageData.cb_ppt_platform_sppt(Math.round(self.value))
} }
} }
if SystemPageData.available.nv-dynamic-boost: SystemSlider { if SystemPageData.nv_dynamic_boost.val != -1: SystemSlider {
text: @tr("nv_dynamic_boost" => "dGPU boost overclock"); text: @tr("nv_dynamic_boost" => "dGPU boost overclock");
minimum: 5; minimum: SystemPageData.nv_dynamic_boost.min;
maximum: 25; maximum: SystemPageData.nv_dynamic_boost.max;
value <=> SystemPageData.nv_dynamic_boost; value: SystemPageData.nv_dynamic_boost.val;
released => { released => {
SystemPageData.set_nv_dynamic_boost(Math.round(SystemPageData.nv_dynamic_boost)) SystemPageData.nv_dynamic_boost.val = self.value;
SystemPageData.cb_nv_dynamic_boost(Math.round(self.value))
} }
} }
if SystemPageData.available.nv-temp-target: SystemSlider { if SystemPageData.nv_temp_target.val != -1: SystemSlider {
text: @tr("nv_temp_target" => "dGPU temperature max"); text: @tr("nv_temp_target" => "dGPU temperature max");
minimum: 75; minimum: SystemPageData.nv_temp_target.min;
maximum: 87; maximum: SystemPageData.nv_temp_target.max;
value <=> SystemPageData.nv_temp_target; value: SystemPageData.nv_temp_target.val;
released => { released => {
SystemPageData.set_nv_temp_target(Math.round(SystemPageData.nv_temp_target)) SystemPageData.nv_temp_target.val = self.value;
SystemPageData.cb_nv_temp_target(Math.round(self.value))
} }
} }
} }
@@ -298,7 +317,7 @@ export component PageSystem inherits Rectangle {
text: @tr("Change EPP based on Throttle Policy"); text: @tr("Change EPP based on Throttle Policy");
checked <=> SystemPageData.throttle_policy_linked_epp; checked <=> SystemPageData.throttle_policy_linked_epp;
toggled => { toggled => {
SystemPageData.set_throttle_policy_linked_epp(SystemPageData.throttle_policy_linked_epp) SystemPageData.cb_throttle_policy_linked_epp(SystemPageData.throttle_policy_linked_epp)
} }
} }
@@ -308,7 +327,7 @@ export component PageSystem inherits Rectangle {
current_value: SystemPageData.energy_performance_choices[SystemPageData.throttle_balanced_epp]; current_value: SystemPageData.energy_performance_choices[SystemPageData.throttle_balanced_epp];
model <=> SystemPageData.energy_performance_choices; model <=> SystemPageData.energy_performance_choices;
selected => { selected => {
SystemPageData.set_throttle_balanced_epp(SystemPageData.throttle_balanced_epp) SystemPageData.cb_throttle_balanced_epp(SystemPageData.throttle_balanced_epp)
} }
} }
@@ -318,7 +337,7 @@ export component PageSystem inherits Rectangle {
current_value: SystemPageData.energy_performance_choices[SystemPageData.throttle_performance_epp]; current_value: SystemPageData.energy_performance_choices[SystemPageData.throttle_performance_epp];
model <=> SystemPageData.energy_performance_choices; model <=> SystemPageData.energy_performance_choices;
selected => { selected => {
SystemPageData.set_throttle_performance_epp(SystemPageData.throttle_performance_epp) SystemPageData.cb_throttle_performance_epp(SystemPageData.throttle_performance_epp)
} }
} }
@@ -328,7 +347,7 @@ export component PageSystem inherits Rectangle {
current_value: SystemPageData.energy_performance_choices[SystemPageData.throttle_quiet_epp]; current_value: SystemPageData.energy_performance_choices[SystemPageData.throttle_quiet_epp];
model <=> SystemPageData.energy_performance_choices; model <=> SystemPageData.energy_performance_choices;
selected => { selected => {
SystemPageData.set_throttle_quiet_epp(SystemPageData.throttle_quiet_epp) SystemPageData.cb_throttle_quiet_epp(SystemPageData.throttle_quiet_epp)
} }
} }
} }
@@ -352,7 +371,7 @@ export component PageSystem inherits Rectangle {
current_value: SystemPageData.throttle_policy_choices[SystemPageData.throttle_policy_on_battery]; current_value: SystemPageData.throttle_policy_choices[SystemPageData.throttle_policy_on_battery];
model <=> SystemPageData.throttle_policy_choices; model <=> SystemPageData.throttle_policy_choices;
selected => { selected => {
SystemPageData.set_throttle_policy_on_battery(SystemPageData.throttle_policy_on_battery) SystemPageData.cb_throttle_policy_on_battery(SystemPageData.throttle_policy_on_battery)
} }
} }
@@ -360,7 +379,7 @@ export component PageSystem inherits Rectangle {
text: @tr("Enabled"); text: @tr("Enabled");
checked <=> SystemPageData.change_throttle_policy_on_battery; checked <=> SystemPageData.change_throttle_policy_on_battery;
toggled => { toggled => {
SystemPageData.set_change_throttle_policy_on_battery(SystemPageData.change_throttle_policy_on_battery); SystemPageData.cb_change_throttle_policy_on_battery(SystemPageData.change_throttle_policy_on_battery);
} }
} }
} }
@@ -373,7 +392,7 @@ export component PageSystem inherits Rectangle {
current_value: SystemPageData.throttle_policy_choices[SystemPageData.throttle_policy_on_ac]; current_value: SystemPageData.throttle_policy_choices[SystemPageData.throttle_policy_on_ac];
model <=> SystemPageData.throttle_policy_choices; model <=> SystemPageData.throttle_policy_choices;
selected => { selected => {
SystemPageData.set_throttle_policy_on_ac(SystemPageData.throttle_policy_on_ac) SystemPageData.cb_throttle_policy_on_ac(SystemPageData.throttle_policy_on_ac)
} }
} }
@@ -381,7 +400,7 @@ export component PageSystem inherits Rectangle {
text: @tr("Enabled"); text: @tr("Enabled");
checked <=> SystemPageData.change_throttle_policy_on_ac; checked <=> SystemPageData.change_throttle_policy_on_ac;
toggled => { toggled => {
SystemPageData.set_change_throttle_policy_on_ac(SystemPageData.change_throttle_policy_on_ac); SystemPageData.cb_change_throttle_policy_on_ac(SystemPageData.change_throttle_policy_on_ac);
} }
} }
} }

View File

@@ -15,30 +15,42 @@ export component SystemSlider inherits RogItem {
in-out property <float> minimum; in-out property <float> minimum;
in-out property <float> maximum; in-out property <float> maximum;
callback released(int); callback released(int);
HorizontalLayout { HorizontalLayout {
HorizontalLayout { HorizontalLayout {
width: 50%; width: 50%;
alignment: LayoutAlignment.space-between; alignment: LayoutAlignment.stretch;
padding-left: 10px; padding-left: 10px;
Text { TouchArea {
font-size: 16px; clicked => {
vertical-alignment: TextVerticalAlignment.center; slider.value += 1;
color: Palette.control-foreground; if slider.value > slider.maximum {
text <=> root.text; slider.value = slider.minimum;
} }
}
Text { HorizontalLayout {
font-size: 16px; spacing: 6px;
vertical-alignment: TextVerticalAlignment.center; Text {
color: Palette.control-foreground; font-size: 16px;
text: "\{Math.round(root.value)}"; vertical-alignment: TextVerticalAlignment.center;
color: Palette.control-foreground;
text <=> root.text;
}
Text {
font-size: 16px;
horizontal-alignment: TextHorizontalAlignment.right;
vertical-alignment: TextVerticalAlignment.center;
color: Palette.control-foreground;
text: "\{Math.round(root.value)}";
}
}
} }
} }
HorizontalBox { HorizontalBox {
// alignment: LayoutAlignment.end; // alignment: LayoutAlignment.end;
padding-right: 20px; padding-right: 20px;
Slider { slider := Slider {
maximum: root.maximum; maximum: root.maximum;
minimum: root.minimum; minimum: root.minimum;
value <=> root.value; value <=> root.value;
@@ -80,6 +92,38 @@ export component SystemToggle inherits RogItem {
} }
} }
export component SystemToggleInt inherits RogItem {
in property <string> text;
// in-out property <bool> checked;
in-out property <int> checked_int;
callback toggled(int);
HorizontalLayout {
spacing: 6px;
HorizontalLayout {
alignment: LayoutAlignment.start;
padding-left: 10px;
Text {
font-size: 16px;
vertical-alignment: TextVerticalAlignment.center;
color: Palette.control-foreground;
text <=> root.text;
}
}
HorizontalLayout {
alignment: LayoutAlignment.end;
padding-right: 20px;
Switch {
checked: root.checked_int != 0;
toggled => {
root.checked_int = self.checked ? 1 : 0;
root.toggled(root.checked_int);
}
}
}
}
}
export component SystemToggleVert inherits RogItem { export component SystemToggleVert inherits RogItem {
in property <string> text; in property <string> text;
in-out property <bool> checked; in-out property <bool> checked;

View File

@@ -42,6 +42,7 @@ component SideBarItem inherits Rectangle {
label := Text { label := Text {
color: Palette.foreground; color: Palette.foreground;
vertical-alignment: center; vertical-alignment: center;
font-size: 14px;
} }
} }

View File

@@ -2,6 +2,7 @@
//! //!
//! `zbus-xmlgen system xyz.ljones.Asusd //! `zbus-xmlgen system xyz.ljones.Asusd
//! /xyz/ljones/asus_armoury/nv_temp_target` //! /xyz/ljones/asus_armoury/nv_temp_target`
use rog_platform::firmware_attributes::FirmwareAttribute;
use zbus::proxy; use zbus::proxy;
#[proxy( #[proxy(
interface = "xyz.ljones.AsusArmoury", interface = "xyz.ljones.AsusArmoury",
@@ -41,7 +42,7 @@ pub trait AsusArmoury {
/// Name property /// Name property
#[zbus(property)] #[zbus(property)]
fn name(&self) -> zbus::Result<String>; fn name(&self) -> zbus::Result<FirmwareAttribute>;
/// ScalarIncrement property. The increment steps that `current_value` may /// ScalarIncrement property. The increment steps that `current_value` may
/// take. Returns `-1` if not used or set. /// take. Returns `-1` if not used or set.

View File

@@ -4,7 +4,7 @@ use std::path::{Path, PathBuf};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use typeshare::typeshare; use typeshare::typeshare;
use zbus::zvariant::Type; use zbus::zvariant::{OwnedValue, Type, Value};
use crate::error::PlatformError; use crate::error::PlatformError;
@@ -254,32 +254,33 @@ define_attribute_getters!(
/// CamelCase names of the properties. Intended for use with DBUS /// CamelCase names of the properties. Intended for use with DBUS
#[typeshare] #[typeshare]
#[repr(u8)] #[repr(u8)]
#[derive(Debug, Clone, Copy, Serialize, Deserialize, Type, PartialEq, PartialOrd)] #[derive(Clone, Copy, Serialize, Deserialize, Type, Value, OwnedValue, PartialEq, PartialOrd)]
#[zvariant(signature = "s")] #[zvariant(signature = "s")]
pub enum FirmwareAttribute { pub enum FirmwareAttribute {
ApuMem, ApuMem = 0,
CoresPerformance, CoresPerformance = 1,
CoresEfficiency, CoresEfficiency = 2,
PptPl1Spl, PptPl1Spl = 3,
PptPl2Sppt, PptPl2Sppt = 4,
PptApuSppt, PptApuSppt = 5,
PptPlatformSppt, PptPlatformSppt = 6,
PptFppt, PptFppt = 7,
NvDynamicBoost, NvDynamicBoost = 8,
NvTempTarget, NvTempTarget = 9,
DgpuBaseTgp, DgpuBaseTgp = 10,
DgpuTgp, DgpuTgp = 11,
ChargeMode, ChargeMode = 12,
BootSound, BootSound = 13,
McuPowersave, McuPowersave = 14,
PanelOverdrive, PanelOverdrive = 15,
PanelHdMode, PanelHdMode = 16,
EgpuConnected, EgpuConnected = 17,
EgpuEnable, EgpuEnable = 18,
DgpuDisable, DgpuDisable = 19,
GpuMuxMode, GpuMuxMode = 20,
MiniLedMode, MiniLedMode = 21,
PendingReboot, PendingReboot = 22,
None = 23,
} }
impl From<&str> for FirmwareAttribute { impl From<&str> for FirmwareAttribute {
@@ -313,7 +314,7 @@ impl From<&str> for FirmwareAttribute {
} }
} }
impl From<FirmwareAttribute> for &'static str { impl From<FirmwareAttribute> for &str {
fn from(attr: FirmwareAttribute) -> Self { fn from(attr: FirmwareAttribute) -> Self {
match attr { match attr {
FirmwareAttribute::ApuMem => "apu_mem", FirmwareAttribute::ApuMem => "apu_mem",
@@ -339,6 +340,7 @@ impl From<FirmwareAttribute> for &'static str {
FirmwareAttribute::GpuMuxMode => "gpu_mux_mode", FirmwareAttribute::GpuMuxMode => "gpu_mux_mode",
FirmwareAttribute::MiniLedMode => "mini_led_mode", FirmwareAttribute::MiniLedMode => "mini_led_mode",
FirmwareAttribute::PendingReboot => "pending_reboot", FirmwareAttribute::PendingReboot => "pending_reboot",
FirmwareAttribute::None => "none",
} }
} }
} }