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",
"simulators", "rog-scsi",
]
default-members = [
"asusctl",
"asusd",
"asusd-user",
"cpuctl",
"rog-control-center",
]
[workspace.dependencies]
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>> {
let name = attr.name()?;
println!("{name}:");
println!("{}:", <&str>::from(name));
let attrs = attr.available_attrs()?;
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 attr in attr.iter() {
let name = attr.name()?;
if name == cmd[0] {
if <&str>::from(name) == cmd[0] {
attr.set_current_value(cmd[1].parse()?)?;
print_firmware_attr(attr)?;
}

View File

@@ -1,5 +1,7 @@
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 zbus::zvariant::{ObjectPath, OwnedObjectPath, OwnedValue, Type, Value};
use zbus::{fdo, interface, Connection};
@@ -46,8 +48,8 @@ impl AsusArmouryAttribute {
#[interface(name = "xyz.ljones.AsusArmoury")]
impl AsusArmouryAttribute {
#[zbus(property)]
async fn name(&self) -> String {
self.0.name().to_string()
async fn name(&self) -> FirmwareAttribute {
self.0.name().into()
}
#[zbus(property)]

View File

@@ -5,7 +5,6 @@ use std::sync::Arc;
use config_traits::StdConfig;
use log::{debug, error, info, warn};
use rog_platform::cpu::{CPUControl, CPUGovernor, CPUEPP};
// use rog_platform::firmware_attributes::FirmwareAttributes;
use rog_platform::platform::{GpuMode, Properties, RogPlatform, ThrottlePolicy};
use rog_platform::power::AsusPower;
use zbus::export::futures_util::lock::Mutex;
@@ -96,7 +95,6 @@ impl CtrlPlatform {
config_path: &Path,
signal_context: SignalEmitter<'static>,
) -> Result<Self, RogError> {
// let attrs = FirmwareAttributes::new();
let platform = RogPlatform::new()?;
let power = AsusPower::new()?;

View File

@@ -15,7 +15,7 @@ pub mod notify;
pub mod tray;
pub mod types;
pub mod ui;
pub mod zbus;
pub mod zbus_proxies;
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
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::tray::init_tray;
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,
};
use rog_control_center::{print_versions, MainWindow};
@@ -153,6 +153,8 @@ async fn main() -> Result<()> {
state = *lock;
}
// This sleep is required to give the event loop time to react
sleep(Duration::from_millis(300));
if state == AppState::MainWindowShouldOpen {
if let Ok(mut lock) = app_state.lock() {
*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 crate::config::Config;
use crate::zbus::{AppState, ROGCCZbusProxyBlocking};
use crate::zbus_proxies::{AppState, ROGCCZbusProxyBlocking};
const TRAY_LABEL: &str = "ROG Control Center";
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::{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:
// - a link from UI callback -> dbus proxy property
// - a link from dbus property signal -> UI state

View File

@@ -1,40 +1,201 @@
use std::sync::{Arc, Mutex};
use rog_dbus::asus_armoury::AsusArmouryProxy;
use rog_dbus::zbus_platform::{PlatformProxy, PlatformProxyBlocking};
use rog_platform::firmware_attributes::FirmwareAttribute;
use rog_platform::platform::Properties;
use slint::ComponentHandle;
use super::show_toast;
use crate::config::Config;
use crate::{
set_ui_callbacks, set_ui_props_async, AvailableSystemProperties, MainWindow, SystemPageData,
use crate::zbus_proxies::find_iface_async;
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>>) {
let conn = zbus::blocking::Connection::system().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();
log::debug!("Available system properties: {sys_props:?}");
let props = AvailableSystemProperties {
ac_command: true,
bat_command: true,
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),
};
if sys_props.contains(&Properties::ChargeControlEndThreshold) {
ui.global::<SystemPageData>()
.set_charge_control_end_threshold(60.0);
}
}
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>>) {
@@ -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
let conn = zbus::Connection::system().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!(
handle,
@@ -74,169 +238,78 @@ pub fn setup_system_page_callbacks(ui: &MainWindow, _states: Arc<Mutex<Config>>)
change_throttle_policy_on_ac
);
set_ui_props_async!(handle, platform, SystemPageData, panel_od);
set_ui_props_async!(handle, platform, SystemPageData, boot_sound);
set_ui_props_async!(handle, platform, SystemPageData, mini_led_mode);
set_ui_props_async!(handle, platform, SystemPageData, ppt_pl1_spl);
set_ui_props_async!(handle, platform, SystemPageData, ppt_pl2_sppt);
set_ui_props_async!(handle, platform, SystemPageData, ppt_fppt);
set_ui_props_async!(handle, platform, SystemPageData, ppt_apu_sppt);
set_ui_props_async!(handle, platform, SystemPageData, ppt_platform_sppt);
set_ui_props_async!(handle, platform, SystemPageData, nv_dynamic_boost);
set_ui_props_async!(handle, platform, SystemPageData, nv_temp_target);
let sys_props = platform.supported_properties().await.unwrap();
log::debug!("Available system properties: {sys_props:?}");
let props = AvailableSystemProperties {
ac_command: true,
bat_command: true,
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),
};
// TODO: move the fail/sucess messages to slint
handle
.upgrade_in_event_loop(move |handle| {
handle.global::<SystemPageData>().set_available(props);
set_ui_callbacks!(handle,
SystemPageData(as f32),
platform.charge_control_end_threshold(as u8),
"Charge limit successfully set to {}",
"Setting Charge limit failed"
);
set_ui_callbacks!(
handle,
SystemPageData(),
platform.panel_od(),
"Panel OverDrive successfully set to {}",
"Setting Panel OverDrive failed"
);
set_ui_callbacks!(
handle,
SystemPageData(),
platform.boot_sound(),
"POST Animation sound successfully set to {}",
"Setting POST Animation sound failed"
);
set_ui_callbacks!(
handle,
SystemPageData(),
platform.mini_led_mode(),
"MiniLED mode successfully set to {}",
"Setting MiniLED mode failed"
);
set_ui_callbacks!(handle,
SystemPageData(as i32),
platform.throttle_thermal_policy(.into()),
"Throttle policy set to {}",
"Setting Throttle policy failed"
);
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();
for attr in armoury_attrs {
if let Ok(value) = attr.current_value().await {
let name = attr.name().await.unwrap();
handle
.upgrade_in_event_loop(move |handle| match name {
FirmwareAttribute::ApuMem => {}
FirmwareAttribute::CoresPerformance => {}
FirmwareAttribute::CoresEfficiency => {}
FirmwareAttribute::PptPl1Spl => {
init_minmax_property!(ppt_pl1_spl, handle, attr);
setup_callback!(ppt_pl1_spl, handle, attr, i32);
setup_minmax_external!(ppt_pl1_spl, handle, attr);
}
FirmwareAttribute::PptPl2Sppt => {
init_minmax_property!(ppt_pl2_sppt, handle, attr);
setup_callback!(ppt_pl2_sppt, handle, attr, i32);
setup_minmax_external!(ppt_pl2_sppt, handle, attr);
}
FirmwareAttribute::PptApuSppt => {
init_minmax_property!(ppt_apu_sppt, handle, attr);
setup_callback!(ppt_apu_sppt, handle, attr, i32);
setup_minmax_external!(ppt_apu_sppt, handle, attr);
}
FirmwareAttribute::PptPlatformSppt => {
init_minmax_property!(ppt_platform_sppt, handle, attr);
setup_callback!(ppt_platform_sppt, handle, attr, i32);
setup_minmax_external!(ppt_platform_sppt, handle, attr);
}
FirmwareAttribute::PptFppt => {
init_minmax_property!(ppt_fppt, handle, attr);
setup_callback!(ppt_fppt, handle, attr, i32);
setup_minmax_external!(ppt_fppt, handle, attr);
}
FirmwareAttribute::NvDynamicBoost => {
init_minmax_property!(nv_dynamic_boost, handle, attr);
setup_callback!(nv_dynamic_boost, handle, attr, i32);
setup_minmax_external!(nv_dynamic_boost, handle, attr);
}
FirmwareAttribute::NvTempTarget => {
init_minmax_property!(nv_temp_target, handle, attr);
setup_callback!(nv_temp_target, handle, attr, i32);
setup_minmax_external!(nv_temp_target, handle, attr);
}
FirmwareAttribute::DgpuBaseTgp => {}
FirmwareAttribute::DgpuTgp => {}
FirmwareAttribute::ChargeMode => {}
FirmwareAttribute::BootSound => {
init_property!(boot_sound, handle, value, i32);
setup_callback!(boot_sound, handle, attr, i32);
setup_external!(boot_sound, i32, handle, attr, value)
}
FirmwareAttribute::McuPowersave => {}
FirmwareAttribute::PanelOverdrive => {
init_property!(panel_overdrive, handle, value, i32);
setup_callback!(panel_overdrive, handle, attr, i32);
setup_external!(panel_overdrive, i32, handle, attr, value)
}
FirmwareAttribute::PanelHdMode => {}
FirmwareAttribute::EgpuConnected => {}
FirmwareAttribute::EgpuEnable => {}
FirmwareAttribute::DgpuDisable => {}
FirmwareAttribute::GpuMuxMode => {}
FirmwareAttribute::MiniLedMode => {
init_property!(mini_led_mode, handle, value, i32);
setup_callback!(mini_led_mode, handle, attr, i32);
setup_external!(mini_led_mode, i32, handle, attr, value)
}
FirmwareAttribute::PendingReboot => {}
FirmwareAttribute::None => {}
})
.ok();
}
}
});
}

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 ""
msgstr ""
"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"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -12,157 +12,157 @@ msgstr ""
"Language: \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"
msgid "Balanced"
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"
msgid "Performance"
msgstr ""
#: rog-control-center/ui/pages/system.slint:26
#: rog-control-center/ui/pages/system.slint:8
msgctxt "SystemPageData"
msgid "Quiet"
msgstr ""
#: rog-control-center/ui/pages/system.slint:29
#: rog-control-center/ui/pages/system.slint:11
msgctxt "SystemPageData"
msgid "Default"
msgstr ""
#: rog-control-center/ui/pages/system.slint:31
#: rog-control-center/ui/pages/system.slint:13
msgctxt "SystemPageData"
msgid "BalancePerformance"
msgstr ""
#: rog-control-center/ui/pages/system.slint:32
#: rog-control-center/ui/pages/system.slint:14
msgctxt "SystemPageData"
msgid "BalancePower"
msgstr ""
#: rog-control-center/ui/pages/system.slint:33
#: rog-control-center/ui/pages/system.slint:15
msgctxt "SystemPageData"
msgid "Power"
msgstr ""
#: rog-control-center/ui/pages/system.slint:110
#: rog-control-center/ui/pages/system.slint:76
msgctxt "PageSystem"
msgid "Base system settings"
msgstr ""
#: rog-control-center/ui/pages/system.slint:115
#: rog-control-center/ui/pages/system.slint:81
msgctxt "PageSystem"
msgid "Charge limit"
msgstr ""
#: rog-control-center/ui/pages/system.slint:127
#: rog-control-center/ui/pages/system.slint:93
msgctxt "PageSystem"
msgid "Throttle Policy"
msgstr ""
#: rog-control-center/ui/pages/system.slint:137
#: rog-control-center/ui/pages/system.slint:103
msgctxt "PageSystem"
msgid "Advanced"
msgstr ""
#: rog-control-center/ui/pages/system.slint:149
#: rog-control-center/ui/pages/system.slint:115
msgctxt "PageSystem"
msgid "Panel Overdrive"
msgstr ""
#: rog-control-center/ui/pages/system.slint:157
#: rog-control-center/ui/pages/system.slint:123
msgctxt "PageSystem"
msgid "MiniLED Mode"
msgstr ""
#: rog-control-center/ui/pages/system.slint:165
#: rog-control-center/ui/pages/system.slint:131
msgctxt "PageSystem"
msgid "POST boot sound"
msgstr ""
#: rog-control-center/ui/pages/system.slint:183
#: rog-control-center/ui/pages/system.slint:149
msgctxt "PageSystem"
msgid "System performance settings"
msgstr ""
#: rog-control-center/ui/pages/system.slint:188
#: rog-control-center/ui/pages/system.slint:154
msgctxt "ppt_pl1_spl"
msgid "PL1, sustained power limit"
msgstr ""
#: rog-control-center/ui/pages/system.slint:198
#: rog-control-center/ui/pages/system.slint:164
msgctxt "ppt_pl2_sppt"
msgid "PL2, turbo power limit"
msgstr ""
#: rog-control-center/ui/pages/system.slint:208
#: rog-control-center/ui/pages/system.slint:174
msgctxt "ppt_fppt"
msgid "FPPT, Fast Power Limit"
msgstr ""
#: rog-control-center/ui/pages/system.slint:218
#: rog-control-center/ui/pages/system.slint:184
msgctxt "ppt_apu_sppt"
msgid "SPPT, APU slow power limit"
msgstr ""
#: rog-control-center/ui/pages/system.slint:228
#: rog-control-center/ui/pages/system.slint:194
msgctxt "ppt_platform_sppt"
msgid "Slow package power tracking limit"
msgstr ""
#: rog-control-center/ui/pages/system.slint:238
#: rog-control-center/ui/pages/system.slint:204
msgctxt "nv_dynamic_boost"
msgid "dGPU boost overclock"
msgstr ""
#: rog-control-center/ui/pages/system.slint:248
#: rog-control-center/ui/pages/system.slint:214
msgctxt "nv_temp_target"
msgid "dGPU temperature max"
msgstr ""
#: rog-control-center/ui/pages/system.slint:294
#: rog-control-center/ui/pages/system.slint:260
msgctxt "PageSystem"
msgid "Energy Performance Preference linked to Throttle Policy"
msgstr ""
#: rog-control-center/ui/pages/system.slint:298
#: rog-control-center/ui/pages/system.slint:264
msgctxt "PageSystem"
msgid "Change EPP based on Throttle Policy"
msgstr ""
#: rog-control-center/ui/pages/system.slint:306
#: rog-control-center/ui/pages/system.slint:272
msgctxt "PageSystem"
msgid "EPP for Balanced Policy"
msgstr ""
#: rog-control-center/ui/pages/system.slint:316
#: rog-control-center/ui/pages/system.slint:282
msgctxt "PageSystem"
msgid "EPP for Performance Policy"
msgstr ""
#: rog-control-center/ui/pages/system.slint:326
#: rog-control-center/ui/pages/system.slint:292
msgctxt "PageSystem"
msgid "EPP for Quiet Policy"
msgstr ""
#: rog-control-center/ui/pages/system.slint:344
#: rog-control-center/ui/pages/system.slint:310
msgctxt "PageSystem"
msgid "Throttle Policy for power state"
msgstr ""
#: rog-control-center/ui/pages/system.slint:350
#: rog-control-center/ui/pages/system.slint:316
msgctxt "PageSystem"
msgid "Throttle Policy on Battery"
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"
msgid "Enabled"
msgstr ""
#: rog-control-center/ui/pages/system.slint:371
#: rog-control-center/ui/pages/system.slint:337
msgctxt "PageSystem"
msgid "Throttle Policy on AC"
msgstr ""

View File

@@ -1,6 +1,6 @@
import { Palette, Button, VerticalBox } from "std-widgets.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 { PageAbout } from "pages/about.slint";
import { PageFans } from "pages/fans.slint";
@@ -15,7 +15,7 @@ import { AuraPageData, AuraDevType, LaptopAuraPower, AuraPowerState, PowerZones,
export { AuraPageData, AuraDevType, LaptopAuraPower, AuraPowerState, PowerZones, AuraEffect }
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 {
title: "ROG Control";
@@ -134,7 +134,8 @@ export component MainWindow inherits Window {
y: 0px;
width: root.width;
height: 32px;
opacity: 0.8;
opacity: 1.0;
background: Colors.grey;
TouchArea {
height: 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";
export struct AvailableSystemProperties {
charge_control_end_threshold: bool,
panel_od: bool,
boot_sound: bool,
mini_led_mode: bool,
disable_nvidia_powerd_on_battery: bool,
ac_command: bool,
bat_command: bool,
throttle_thermal_policy: bool,
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 struct AttrMinMax {
min: int,
max: int,
val: float,
}
export struct AttrPossible {
range: [int],
val: int,
}
export global SystemPageData {
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 <[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: [
@tr("Default"),
@tr("Performance"),
@@ -33,59 +26,78 @@ export global SystemPageData {
@tr("Power")
];
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;
callback set_throttle_performance_epp(int);
callback cb_throttle_performance_epp(int);
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
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;
callback set_throttle_policy_on_ac(int);
callback cb_throttle_policy_on_ac(int);
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;
callback set_throttle_policy_on_battery(int);
callback cb_throttle_policy_on_battery(int);
in-out property <bool> change_throttle_policy_on_battery: true;
callback set_change_throttle_policy_on_battery(bool);
in-out property <bool> panel_od;
callback set_panel_od(bool);
in-out property <bool> boot_sound;
callback set_boot_sound(bool);
in-out property <bool> mini_led_mode;
callback set_mini_led_mode(bool);
in-out property <float> ppt_pl1_spl: 5;
callback set_ppt_pl1_spl(int);
in-out property <float> ppt_pl2_sppt: 5;
callback set_ppt_pl2_sppt(int);
in-out property <float> ppt_fppt: 5;
callback set_ppt_fppt(int);
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_change_throttle_policy_on_battery(bool);
//
in-out property <int> panel_overdrive;
callback cb_panel_overdrive(int);
in-out property <int> boot_sound;
callback cb_boot_sound(int);
in-out property <int> mini_led_mode;
callback cb_mini_led_mode(int);
in-out property <AttrMinMax> ppt_pl1_spl: {
min: 0,
max: 100,
val: 20,
};
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 {
@@ -107,21 +119,21 @@ export component PageSystem inherits Rectangle {
font-size: 18px;
color: Palette.control-foreground;
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");
minimum: 20;
maximum: 100;
value <=> SystemPageData.charge_control_end_threshold;
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;
SystemDropdown {
text: @tr("Throttle Policy");
@@ -129,7 +141,7 @@ export component PageSystem inherits Rectangle {
current_value: SystemPageData.throttle_policy_choices[SystemPageData.throttle_thermal_policy];
model <=> SystemPageData.throttle_policy_choices;
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 {
background: Palette.alternate-background;
border-color: Palette.accent-background;
@@ -180,77 +164,112 @@ export component PageSystem inherits Rectangle {
font-size: 18px;
color: Palette.control-foreground;
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");
minimum: 5;
maximum: 250;
value <=> SystemPageData.ppt_pl1_spl;
minimum: SystemPageData.ppt_pl1_spl.min;
maximum: SystemPageData.ppt_pl1_spl.max;
value: SystemPageData.ppt_pl1_spl.val;
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");
minimum: 5;
maximum: 250;
value <=> SystemPageData.ppt_pl2_sppt;
minimum: SystemPageData.ppt_pl2_sppt.min;
maximum: SystemPageData.ppt_pl2_sppt.max;
value: SystemPageData.ppt_pl2_sppt.val;
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");
minimum: 5;
maximum: 250;
value <=> SystemPageData.ppt_fppt;
minimum: SystemPageData.ppt_fppt.min;
maximum: SystemPageData.ppt_fppt.max;
value: SystemPageData.ppt_fppt.val;
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");
minimum: 5;
maximum: 130;
value <=> SystemPageData.ppt_apu_sppt;
minimum: SystemPageData.ppt_apu_sppt.min;
maximum: SystemPageData.ppt_apu_sppt.max;
value: SystemPageData.ppt_apu_sppt.val;
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");
maximum: 130;
minimum: 5;
value <=> SystemPageData.ppt_platform_sppt;
minimum: SystemPageData.ppt_platform_sppt.min;
maximum: SystemPageData.ppt_platform_sppt.max;
value: SystemPageData.ppt_platform_sppt.val;
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");
minimum: 5;
maximum: 25;
value <=> SystemPageData.nv_dynamic_boost;
minimum: SystemPageData.nv_dynamic_boost.min;
maximum: SystemPageData.nv_dynamic_boost.max;
value: SystemPageData.nv_dynamic_boost.val;
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");
minimum: 75;
maximum: 87;
value <=> SystemPageData.nv_temp_target;
minimum: SystemPageData.nv_temp_target.min;
maximum: SystemPageData.nv_temp_target.max;
value: SystemPageData.nv_temp_target.val;
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");
checked <=> SystemPageData.throttle_policy_linked_epp;
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];
model <=> SystemPageData.energy_performance_choices;
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];
model <=> SystemPageData.energy_performance_choices;
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];
model <=> SystemPageData.energy_performance_choices;
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];
model <=> SystemPageData.throttle_policy_choices;
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");
checked <=> SystemPageData.change_throttle_policy_on_battery;
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];
model <=> SystemPageData.throttle_policy_choices;
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");
checked <=> SystemPageData.change_throttle_policy_on_ac;
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> maximum;
callback released(int);
HorizontalLayout {
HorizontalLayout {
width: 50%;
alignment: LayoutAlignment.space-between;
alignment: LayoutAlignment.stretch;
padding-left: 10px;
Text {
font-size: 16px;
vertical-alignment: TextVerticalAlignment.center;
color: Palette.control-foreground;
text <=> root.text;
}
Text {
font-size: 16px;
vertical-alignment: TextVerticalAlignment.center;
color: Palette.control-foreground;
text: "\{Math.round(root.value)}";
TouchArea {
clicked => {
slider.value += 1;
if slider.value > slider.maximum {
slider.value = slider.minimum;
}
}
HorizontalLayout {
spacing: 6px;
Text {
font-size: 16px;
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 {
// alignment: LayoutAlignment.end;
padding-right: 20px;
Slider {
slider := Slider {
maximum: root.maximum;
minimum: root.minimum;
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 {
in property <string> text;
in-out property <bool> checked;

View File

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

View File

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

View File

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