Compare commits

...

8 Commits

Author SHA1 Message Date
Luke Jones de61a15b7a Prep 6.1.0 2025-02-04 18:52:55 +13:00
Luke Jones 16700e55f4 ROGCC: refactor many more parts of the PPT settings 2025-02-04 18:50:48 +13:00
Luke Jones 5833a011ce Merge branch 'g513rc-zonefix' into 'main'
Add basic zones for G513RC

See merge request asus-linux/asusctl!216
2025-02-03 04:08:29 +00:00
loystonpais 62577ee0e4 Add basic zones for G513RC 2025-02-03 07:36:32 +05:30
Luke Jones dac35996b1 Enable use of GAMESCOPE_WAYLAND_DISPLAY 2025-02-02 20:02:51 +13:00
Luke Jones 5c2bcad7c6 Various UI fixes 2025-02-01 20:31:09 +13:00
Luke Jones 36c34cb3dd Merge branch 'fix/anime-animation-crash' into 'main'
fix: Use spawn instead of spawn_local in anime animation callback

Closes #588

See merge request asus-linux/asusctl!213
2025-01-22 02:05:04 +00:00
I-Al-Istannen 9b82b875f1 fix: Use spawn instead of spawn_local in anime animation callback
Closes #588
2025-01-21 21:04:20 +01:00
17 changed files with 1057 additions and 380 deletions
+8
View File
@@ -2,6 +2,14 @@
## [Unreleased] ## [Unreleased]
## [v6.1.0]
### Changed
- Update deps
- Add support for G513RC RGB modes
- Many UI fixes
- Fixes to PPT settings in UI
## [v6.1.0-rc7] ## [v6.1.0-rc7]
- Refactor PPT handling more: - Refactor PPT handling more:
Generated
+805 -203
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -1,5 +1,5 @@
[workspace.package] [workspace.package]
version = "6.1.0-rc7" version = "6.1.0"
rust-version = "1.82" rust-version = "1.82"
license = "MPL-2.0" license = "MPL-2.0"
readme = "README.md" readme = "README.md"
+33 -22
View File
@@ -68,30 +68,41 @@ impl AsusArmouryAttribute {
) -> Result<(), RogError> { ) -> Result<(), RogError> {
use zbus::export::futures_util::StreamExt; use zbus::export::futures_util::StreamExt;
let ctrl = self.clone();
let name = self.name(); let name = self.name();
match self.attr.get_watcher() { macro_rules! watch_value_notify {
Ok(watch) => { ($attr_str:expr, $fn_prop_changed:ident) => {
let name = <&str>::from(name); match self.attr.get_watcher($attr_str) {
tokio::spawn(async move { Ok(watch) => {
let mut buffer = [0; 32]; let name = <&str>::from(name);
watch let ctrl = self.clone();
.into_event_stream(&mut buffer) let sig = signal_ctxt.clone();
.unwrap() tokio::spawn(async move {
.for_each(|_| async { let mut buffer = [0; 32];
debug!("{} changed", name); watch
ctrl.current_value_changed(&signal_ctxt).await.ok(); .into_event_stream(&mut buffer)
}) .unwrap()
.await; .for_each(|_| async {
}); debug!("{} changed", name);
} ctrl.$fn_prop_changed(&sig).await.ok();
Err(e) => info!( })
"inotify watch failed: {}. You can ignore this if your device does not support \ .await;
the feature", });
e }
) Err(e) => info!(
"inotify watch failed: {}. You can ignore this if your device does not \
support the feature",
e
)
}
};
} }
// "current_value", "default_value", "min_value", "max_value"
watch_value_notify!("current_value", current_value_changed);
watch_value_notify!("default_value", default_value_changed);
watch_value_notify!("min_value", min_value_changed);
watch_value_notify!("max_value", max_value_changed);
Ok(()) Ok(())
} }
} }
@@ -406,7 +417,7 @@ pub async fn set_config_or_default(
<&str>::from(name), <&str>::from(name),
i i
); );
config.write(); // config.write();
} }
} }
} }
+1 -1
View File
@@ -176,7 +176,7 @@ impl AniMe {
return Ok(true); // Do safe exit return Ok(true); // Do safe exit
} }
let inner = inner.clone(); let inner = inner.clone();
tokio::task::spawn_local(async move { tokio::task::spawn(async move {
inner inner
.write_data_buffer(frame) .write_data_buffer(frame)
.await .await
+54 -54
View File
@@ -350,34 +350,27 @@ impl CtrlPlatform {
} }
#[zbus(property)] #[zbus(property)]
async fn set_platform_profile(&mut self, policy: PlatformProfile) -> Result<(), FdoErr> { async fn set_platform_profile(
&mut self,
#[zbus(signal_context)] ctxt: SignalEmitter<'_>,
policy: PlatformProfile
) -> Result<(), FdoErr> {
// TODO: watch for external changes // TODO: watch for external changes
if self.platform.has_platform_profile() { if self.platform.has_platform_profile() {
let change_epp = self.config.lock().await.platform_profile_linked_epp; let change_epp = self.config.lock().await.platform_profile_linked_epp;
let epp = self.get_config_epp_for_throttle(policy).await; let epp = self.get_config_epp_for_throttle(policy).await;
self.check_and_set_epp(epp, change_epp); self.check_and_set_epp(epp, change_epp);
let power_plugged = self
.power
.get_online()
.map_err(|e| {
error!("Could not get power status: {e:?}");
e
})
.unwrap_or_default();
self.config
.lock()
.await
.select_tunings(power_plugged == 1, policy)
.enabled = false;
self.config.lock().await.write(); self.config.lock().await.write();
// TODO: Need to get supported profiles here and ensure we translate to one
self.platform self.platform
.set_platform_profile(policy.into()) .set_platform_profile(policy.into())
.map_err(|err| { .map_err(|err| {
warn!("platform_profile {}", err); warn!("platform_profile {}", err);
FdoErr::Failed(format!("RogPlatform: platform_profile: {err}")) FdoErr::Failed(format!("RogPlatform: platform_profile: {err}"))
}) })?;
self.enable_ppt_group_changed(&ctxt).await?;
Ok(())
} else { } else {
Err(FdoErr::NotSupported( Err(FdoErr::NotSupported(
"RogPlatform: platform_profile not supported".to_owned() "RogPlatform: platform_profile not supported".to_owned()
@@ -405,10 +398,11 @@ impl CtrlPlatform {
#[zbus(property)] #[zbus(property)]
async fn set_platform_profile_on_battery( async fn set_platform_profile_on_battery(
&mut self, &mut self,
#[zbus(signal_context)] ctxt: SignalEmitter<'_>,
policy: PlatformProfile policy: PlatformProfile
) -> Result<(), FdoErr> { ) -> Result<(), FdoErr> {
self.config.lock().await.platform_profile_on_battery = policy; self.config.lock().await.platform_profile_on_battery = policy;
self.set_platform_profile(policy).await?; self.set_platform_profile(ctxt, policy).await?;
self.config.lock().await.write(); self.config.lock().await.write();
Ok(()) Ok(())
} }
@@ -431,9 +425,13 @@ impl CtrlPlatform {
} }
#[zbus(property)] #[zbus(property)]
async fn set_platform_profile_on_ac(&mut self, policy: PlatformProfile) -> Result<(), FdoErr> { async fn set_platform_profile_on_ac(
&mut self,
#[zbus(signal_context)] ctxt: SignalEmitter<'_>,
policy: PlatformProfile
) -> Result<(), FdoErr> {
self.config.lock().await.platform_profile_on_ac = policy; self.config.lock().await.platform_profile_on_ac = policy;
self.set_platform_profile(policy).await?; self.set_platform_profile(ctxt, policy).await?;
self.config.lock().await.write(); self.config.lock().await.write();
Ok(()) Ok(())
} }
@@ -532,45 +530,41 @@ impl CtrlPlatform {
.unwrap_or_default(); .unwrap_or_default();
let profile: PlatformProfile = self.platform.get_platform_profile()?.into(); let profile: PlatformProfile = self.platform.get_platform_profile()?.into();
// Clone to reduce blocking if enable {
let tuning = self // Clone to reduce blocking
.config let tuning = self
.lock() .config
.await .lock()
.select_tunings(power_plugged == 1, profile) .await
.clone(); .select_tunings(power_plugged == 1, profile)
.clone();
for attr in self.attributes.attributes() { for attr in self.attributes.attributes() {
let name: FirmwareAttribute = attr.name().into(); let name: FirmwareAttribute = attr.name().into();
if name.is_ppt() { if name.is_ppt() {
// reset stored value // reset stored value
if let Some(tune) = self if let Some(tune) = self
.config .config
.lock() .lock()
.await .await
.select_tunings(power_plugged == 1, profile) .select_tunings(power_plugged == 1, profile)
.group .group
.get_mut(&name) .get_mut(&name)
{ {
let value = if !enable { let value = tuning
attr.default_value().clone()
} else {
tuning
.group .group
.get(&name) .get(&name)
.map(|v| AttrValue::Integer(*v)) .map(|v| AttrValue::Integer(*v))
.unwrap_or_else(|| attr.default_value().clone()) .unwrap_or_else(|| attr.default_value().clone());
}; // restore default
// restore default attr.set_current_value(&value)?;
attr.set_current_value(&value)?; if let AttrValue::Integer(i) = value {
if let AttrValue::Integer(i) = value { *tune = i
*tune = i }
} }
} }
} }
} } else {
if !enable {
// finally, reapply the profile to ensure acpi does the thingy // finally, reapply the profile to ensure acpi does the thingy
self.platform.set_platform_profile(profile.into())?; self.platform.set_platform_profile(profile.into())?;
} }
@@ -682,6 +676,7 @@ impl CtrlTask for CtrlPlatform {
let platform1 = self.clone(); let platform1 = self.clone();
let platform2 = self.clone(); let platform2 = self.clone();
let platform3 = self.clone(); let platform3 = self.clone();
let signal_ctxt_copy = signal_ctxt.clone();
self.create_sys_event_tasks( self.create_sys_event_tasks(
move |sleeping| { move |sleeping| {
let platform1 = platform1.clone(); let platform1 = platform1.clone();
@@ -749,6 +744,7 @@ impl CtrlTask for CtrlPlatform {
}, },
move |power_plugged| { move |power_plugged| {
let platform3 = platform3.clone(); let platform3 = platform3.clone();
let signal_ctxt_copy = signal_ctxt.clone();
// power change // power change
async move { async move {
if platform3.platform.has_platform_profile() { if platform3.platform.has_platform_profile() {
@@ -780,6 +776,10 @@ impl CtrlTask for CtrlPlatform {
profile profile
) )
.await; .await;
platform3
.enable_ppt_group_changed(&signal_ctxt_copy)
.await
.ok();
} }
} }
} }
@@ -788,7 +788,7 @@ impl CtrlTask for CtrlPlatform {
// This spawns a new task for every item. // This spawns a new task for every item.
// TODO: find a better way to manage this // TODO: find a better way to manage this
self.watch_charge_control_end_threshold(signal_ctxt.clone()) self.watch_charge_control_end_threshold(signal_ctxt_copy.clone())
.await?; .await?;
let watch_platform_profile = self.platform.monitor_platform_profile()?; let watch_platform_profile = self.platform.monitor_platform_profile()?;
@@ -815,8 +815,8 @@ impl CtrlTask for CtrlPlatform {
let change_epp = ctrl.config.lock().await.platform_profile_linked_epp; let change_epp = ctrl.config.lock().await.platform_profile_linked_epp;
let epp = ctrl.get_config_epp_for_throttle(profile).await; let epp = ctrl.get_config_epp_for_throttle(profile).await;
ctrl.check_and_set_epp(epp, change_epp); ctrl.check_and_set_epp(epp, change_epp);
ctrl.platform_profile_changed(&signal_ctxt).await.ok(); ctrl.platform_profile_changed(&signal_ctxt_copy).await.ok();
ctrl.enable_ppt_group_changed(&signal_ctxt).await.ok(); ctrl.enable_ppt_group_changed(&signal_ctxt_copy).await.ok();
let power_plugged = ctrl let power_plugged = ctrl
.power .power
.get_online() .get_online()
+11 -2
View File
@@ -80,6 +80,15 @@
advanced_type: None, advanced_type: None,
power_zones: [Keyboard], power_zones: [Keyboard],
), ),
(
device_name: "FX617X",
product_id: "",
layout_name: "fa506i",
basic_modes: [Static, Breathe, Pulse],
basic_zones: [],
advanced_type: None,
power_zones: [Keyboard],
),
( (
device_name: "FX705D", device_name: "FX705D",
product_id: "", product_id: "",
@@ -139,7 +148,7 @@
product_id: "", product_id: "",
layout_name: "g513i", layout_name: "g513i",
basic_modes: [Static, Breathe, RainbowCycle, RainbowWave, Pulse], basic_modes: [Static, Breathe, RainbowCycle, RainbowWave, Pulse],
basic_zones: [], basic_zones: [Key1, Key2, Key3, Key4],
advanced_type: Zoned([ZonedKbLeft, ZonedKbLeftMid, ZonedKbRightMid, ZonedKbRight, LightbarRight, LightbarRightCorner, LightbarRightBottom, LightbarLeftBottom, LightbarLeftCorner, LightbarLeft]), advanced_type: Zoned([ZonedKbLeft, ZonedKbLeftMid, ZonedKbRightMid, ZonedKbRight, LightbarRight, LightbarRightCorner, LightbarRightBottom, LightbarLeftBottom, LightbarLeftCorner, LightbarLeft]),
power_zones: [Keyboard, Lightbar], power_zones: [Keyboard, Lightbar],
), ),
@@ -854,4 +863,4 @@
advanced_type: None, advanced_type: None,
power_zones: [Ally], power_zones: [Ally],
), ),
]) ])
+1 -1
View File
@@ -91,7 +91,7 @@ impl LedSupportFile {
/// to ensure we match to *whole names* first before doing a glob match /// to ensure we match to *whole names* first before doing a glob match
fn match_device(&self, device_name: &str, product_id: &str) -> LedSupportData { fn match_device(&self, device_name: &str, product_id: &str) -> LedSupportData {
for config in self.0.iter().rev() { for config in self.0.iter().rev() {
if device_name.contains(&config.device_name) { if device_name.eq_ignore_ascii_case(&config.device_name) {
info!("Matched to {}", config.device_name); info!("Matched to {}", config.device_name);
if !config.product_id.is_empty() { if !config.product_id.is_empty() {
info!("Checking product ID"); info!("Checking product ID");
-2
View File
@@ -5,7 +5,6 @@ use slint_build::CompilerConfiguration;
fn main() { fn main() {
// write_locales(); // write_locales();
let root = env!("CARGO_MANIFEST_DIR"); let root = env!("CARGO_MANIFEST_DIR");
let mut main = PathBuf::from_str(root).unwrap(); let mut main = PathBuf::from_str(root).unwrap();
main.push("ui/main_window.slint"); main.push("ui/main_window.slint");
@@ -14,7 +13,6 @@ fn main() {
include.push("ui"); include.push("ui");
slint_build::print_rustc_flags().unwrap(); slint_build::print_rustc_flags().unwrap();
// slint_build::compile("ui/main_window.slint").unwrap();
slint_build::compile_with_config( slint_build::compile_with_config(
main, main,
CompilerConfiguration::new() CompilerConfiguration::new()
+42 -15
View File
@@ -1,4 +1,4 @@
use std::env::args; use std::env::{self, args};
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::process::exit; use std::process::exit;
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
@@ -32,6 +32,12 @@ async fn main() -> Result<()> {
.format_timestamp(None) .format_timestamp(None)
.init(); .init();
// If we're running under gamescope we have to set WAYLAND_DISPLAY for winit to
// use
if let Ok(gamescope) = env::var("GAMESCOPE_WAYLAND_DISPLAY") {
env::set_var("WAYLAND_DISPLAY", gamescope);
}
// Try to open a proxy and check for app state first // Try to open a proxy and check for app state first
{ {
let user_con = zbus::blocking::Connection::session()?; let user_con = zbus::blocking::Connection::session()?;
@@ -84,7 +90,7 @@ async fn main() -> Result<()> {
let board_name = dmi.board_name; let board_name = dmi.board_name;
let prod_family = dmi.product_family; let prod_family = dmi.product_family;
info!("Running on {board_name}, product: {prod_family}"); info!("Running on {board_name}, product: {prod_family}");
let is_rog_ally = prod_family == "RC71L"; let is_rog_ally = prod_family == "RC71L" || prod_family == "RC72L";
let args: Vec<String> = args().skip(1).collect(); let args: Vec<String> = args().skip(1).collect();
@@ -120,7 +126,9 @@ async fn main() -> Result<()> {
config.enable_tray_icon = false; config.enable_tray_icon = false;
config.run_in_background = false; config.run_in_background = false;
config.startup_in_background = false; config.startup_in_background = false;
config.start_fullscreen = true;
} }
config.write();
let enable_tray_icon = config.enable_tray_icon; let enable_tray_icon = config.enable_tray_icon;
let startup_in_background = config.startup_in_background; let startup_in_background = config.startup_in_background;
@@ -136,8 +144,8 @@ async fn main() -> Result<()> {
// i_slint_backend_selector::with_platform(|_| Ok(())).unwrap(); // i_slint_backend_selector::with_platform(|_| Ok(())).unwrap();
if !startup_in_background { if !startup_in_background {
if let Ok(mut lock) = app_state.lock() { if let Ok(mut app_state) = app_state.lock() {
*lock = AppState::MainWindowShouldOpen; *app_state = AppState::MainWindowShouldOpen;
} }
} }
@@ -154,15 +162,15 @@ async fn main() -> Result<()> {
let mut state = AppState::StartingUp; let mut state = AppState::StartingUp;
loop { loop {
// save as a var, don't hold the lock the entire time or deadlocks happen // save as a var, don't hold the lock the entire time or deadlocks happen
if let Ok(lock) = app_state.lock() { if let Ok(app_state) = app_state.lock() {
state = *lock; state = *app_state;
} }
// This sleep is required to give the event loop time to react // This sleep is required to give the event loop time to react
sleep(Duration::from_millis(300)); 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 app_state) = app_state.lock() {
*lock = AppState::MainWindowOpen; *app_state = AppState::MainWindowOpen;
} }
let config_copy = config.clone(); let config_copy = config.clone();
@@ -174,20 +182,39 @@ async fn main() -> Result<()> {
if let Some(ui) = ui.as_mut() { if let Some(ui) = ui.as_mut() {
ui.window().show().unwrap(); ui.window().show().unwrap();
ui.window().on_close_requested(move || { ui.window().on_close_requested(move || {
if let Ok(mut lock) = app_state_copy.lock() { if let Ok(mut app_state) = app_state_copy.lock() {
*lock = AppState::MainWindowClosed; *app_state = AppState::MainWindowClosed;
} }
slint::CloseRequestResponse::HideWindow slint::CloseRequestResponse::HideWindow
}); });
} else { } else {
let config_copy_2 = config_copy.clone();
let newui = setup_window(config_copy); let newui = setup_window(config_copy);
newui.window().show().unwrap();
newui.window().on_close_requested(move || { newui.window().on_close_requested(move || {
if let Ok(mut lock) = app_state_copy.lock() { if let Ok(mut app_state) = app_state_copy.lock() {
*lock = AppState::MainWindowClosed; *app_state = AppState::MainWindowClosed;
} }
slint::CloseRequestResponse::HideWindow slint::CloseRequestResponse::HideWindow
}); });
let ui_copy = newui.as_weak();
newui
.window()
.set_rendering_notifier(move |s, _| {
if let slint::RenderingState::RenderingSetup = s {
let config = config_copy_2.clone();
ui_copy
.upgrade_in_event_loop(move |w| {
let fullscreen =
config.lock().is_ok_and(|c| c.start_fullscreen);
if fullscreen && !w.window().is_fullscreen() {
w.window().set_fullscreen(fullscreen);
}
})
.ok();
}
})
.ok();
ui.replace(newui); ui.replace(newui);
} }
}); });
@@ -197,8 +224,8 @@ async fn main() -> Result<()> {
slint::quit_event_loop().unwrap(); slint::quit_event_loop().unwrap();
exit(0); exit(0);
} else if state != AppState::MainWindowOpen { } else if state != AppState::MainWindowOpen {
if let Ok(lock) = config.lock() { if let Ok(config) = config.lock() {
if !lock.run_in_background { if !config.run_in_background {
slint::quit_event_loop().unwrap(); slint::quit_event_loop().unwrap();
exit(0); exit(0);
} }
+3 -10
View File
@@ -8,7 +8,7 @@ use std::sync::{Arc, Mutex};
use config_traits::StdConfig; use config_traits::StdConfig;
use log::warn; use log::warn;
use rog_dbus::list_iface_blocking; use rog_dbus::list_iface_blocking;
use slint::{ComponentHandle, PhysicalSize, SharedString, Weak}; use slint::{ComponentHandle, SharedString, Weak};
use crate::config::Config; use crate::config::Config;
use crate::ui::setup_anime::setup_anime_page; use crate::ui::setup_anime::setup_anime_page;
@@ -87,15 +87,7 @@ pub fn setup_window(config: Arc<Mutex<Config>>) -> MainWindow {
.map_err(|e| warn!("Couldn't set application ID: {e:?}")) .map_err(|e| warn!("Couldn't set application ID: {e:?}"))
.ok(); .ok();
let ui = MainWindow::new().unwrap(); let ui = MainWindow::new().unwrap();
if let Ok(lock) = config.try_lock() { ui.window().show().unwrap();
let fullscreen = lock.start_fullscreen;
let width = lock.fullscreen_width;
let height = lock.fullscreen_height;
if fullscreen {
ui.window().set_fullscreen(fullscreen);
ui.window().set_size(PhysicalSize { width, height });
}
};
let available = list_iface_blocking().unwrap_or_default(); let available = list_iface_blocking().unwrap_or_default();
ui.set_sidebar_items_avilable( ui.set_sidebar_items_avilable(
@@ -129,6 +121,7 @@ pub fn setup_window(config: Arc<Mutex<Config>>) -> MainWindow {
if available.contains(&"xyz.ljones.FanCurves".to_string()) { if available.contains(&"xyz.ljones.FanCurves".to_string()) {
setup_fan_curve_page(&ui, config); setup_fan_curve_page(&ui, config);
} }
ui ui
} }
+31 -21
View File
@@ -16,12 +16,12 @@ use crate::{set_ui_callbacks, set_ui_props_async, AttrMinMax, MainWindow, System
const MINMAX: AttrMinMax = AttrMinMax { const MINMAX: AttrMinMax = AttrMinMax {
min: 0, min: 0,
max: 0, max: 0,
val: -1.0 current: -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::builder(&conn).build().unwrap();
// let armoury_attrs = // let armoury_attrs =
// find_iface::<AsusArmouryProxyBlocking>("xyz.ljones.AsusArmoury").unwrap(); // find_iface::<AsusArmouryProxyBlocking>("xyz.ljones.AsusArmoury").unwrap();
@@ -93,13 +93,13 @@ macro_rules! init_minmax_property {
tokio::spawn(async move { tokio::spawn(async move {
let min = proxy_copy.min_value().await.unwrap(); let min = proxy_copy.min_value().await.unwrap();
let max = proxy_copy.max_value().await.unwrap(); let max = proxy_copy.max_value().await.unwrap();
let val = proxy_copy.current_value().await.unwrap() as f32; let current = proxy_copy.current_value().await.unwrap() as f32;
handle_copy handle_copy
.upgrade_in_event_loop(move |handle| { .upgrade_in_event_loop(move |handle| {
concat_idents!(setter = set_, $property { concat_idents!(setter = set_, $property {
handle handle
.global::<SystemPageData>() .global::<SystemPageData>()
.setter(AttrMinMax { min, max, val }); .setter(AttrMinMax { min, max, current });
}); });
}) })
.ok(); .ok();
@@ -174,30 +174,40 @@ macro_rules! setup_external {
} }
// For handling external value changes // For handling external value changes
macro_rules! setup_minmax_external { macro_rules! setup_value_watch {
($property:ident, $handle:expr, $attr:expr, $platform:expr) => { ($property:ident, $handle:expr, $proxy:expr, $value_type:ident $($conv: tt)*) => {
let handle_copy = $handle.as_weak(); let handle_copy = $handle.as_weak();
let proxy_copy = $attr.clone(); let proxy_copy = $proxy.clone();
tokio::spawn(async move { tokio::spawn(async move {
let mut x = proxy_copy.receive_current_value_changed().await; let mut x = concat_idents!(recv = receive_, $value_type, _value_changed {
proxy_copy.recv().await
});
use zbus::export::futures_util::StreamExt; use zbus::export::futures_util::StreamExt;
while let Some(e) = x.next().await { while let Some(e) = x.next().await {
if let Ok(out) = e.get().await { if let Ok(out) = e.get().await {
concat_idents!(getter = get_, $property { concat_idents!(getter = get_, $property {
handle_copy handle_copy
.upgrade_in_event_loop(move |handle| { .upgrade_in_event_loop(move |handle| {
let mut tmp: AttrMinMax = let mut tmp: AttrMinMax =
handle.global::<SystemPageData>().getter(); handle.global::<SystemPageData>().getter();
tmp.val = out as f32; tmp.$value_type = out $($conv)*;
concat_idents!(setter = set_, $property { concat_idents!(setter = set_, $property {
handle.global::<SystemPageData>().setter(tmp); handle.global::<SystemPageData>().setter(tmp);
}); });
}) })
.ok(); .ok();
}); });
} }
} }
}); });
};
}
macro_rules! setup_minmax_external {
($property:ident, $handle:expr, $attr:expr, $platform:expr) => {
setup_value_watch!($property, $handle, $attr, current as f32);
setup_value_watch!($property, $handle, $attr, min);
setup_value_watch!($property, $handle, $attr, max);
let handle_copy = $handle.as_weak(); let handle_copy = $handle.as_weak();
let proxy_copy = $attr.clone(); let proxy_copy = $attr.clone();
@@ -210,13 +220,13 @@ macro_rules! setup_minmax_external {
debug!("receive_platform_profile_changed, getting new {}", stringify!(attr)); debug!("receive_platform_profile_changed, getting new {}", stringify!(attr));
let min = proxy_copy.min_value().await.unwrap(); let min = proxy_copy.min_value().await.unwrap();
let max = proxy_copy.max_value().await.unwrap(); let max = proxy_copy.max_value().await.unwrap();
let val = proxy_copy.current_value().await.unwrap() as f32; let current = proxy_copy.current_value().await.unwrap() as f32;
handle_copy handle_copy
.upgrade_in_event_loop(move |handle| { .upgrade_in_event_loop(move |handle| {
concat_idents!(setter = set_, $property { concat_idents!(setter = set_, $property {
handle handle
.global::<SystemPageData>() .global::<SystemPageData>()
.setter(AttrMinMax { min, max, val }); .setter(AttrMinMax { min, max, current });
}); });
}) })
.ok(); .ok();
@@ -249,7 +259,7 @@ pub fn setup_system_page_callbacks(ui: &MainWindow, _states: Arc<Mutex<Config>>)
tokio::spawn(async move { tokio::spawn(async move {
// 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::builder(&conn).build().await.unwrap();
set_ui_props_async!( set_ui_props_async!(
handle, handle,
@@ -2,7 +2,7 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2025-01-21 06:49+0000\n" "POT-Creation-Date: 2025-02-01 07:31+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"
@@ -733,42 +733,42 @@ msgctxt "confirm_reset"
msgid "Are you sure you want to reset this?" msgid "Are you sure you want to reset this?"
msgstr "" msgstr ""
#: rog-control-center/ui/main_window.slint:54 #: rog-control-center/ui/main_window.slint:55
msgctxt "MainWindow" msgctxt "MainWindow"
msgid "ROG" msgid "ROG"
msgstr "" msgstr ""
#: rog-control-center/ui/main_window.slint:56 #: rog-control-center/ui/main_window.slint:57
msgctxt "Menu1" msgctxt "Menu1"
msgid "System Control" msgid "System Control"
msgstr "" msgstr ""
#: rog-control-center/ui/main_window.slint:57 #: rog-control-center/ui/main_window.slint:58
msgctxt "Menu2" msgctxt "Menu2"
msgid "Keyboard Aura" msgid "Keyboard Aura"
msgstr "" msgstr ""
#: rog-control-center/ui/main_window.slint:58 #: rog-control-center/ui/main_window.slint:59
msgctxt "Menu3" msgctxt "Menu3"
msgid "AniMe Matrix" msgid "AniMe Matrix"
msgstr "" msgstr ""
#: rog-control-center/ui/main_window.slint:59 #: rog-control-center/ui/main_window.slint:60
msgctxt "Menu4" msgctxt "Menu4"
msgid "Fan Curves" msgid "Fan Curves"
msgstr "" msgstr ""
#: rog-control-center/ui/main_window.slint:60 #: rog-control-center/ui/main_window.slint:61
msgctxt "Menu5" msgctxt "Menu5"
msgid "App Settings" msgid "App Settings"
msgstr "" msgstr ""
#: rog-control-center/ui/main_window.slint:61 #: rog-control-center/ui/main_window.slint:62
msgctxt "Menu6" msgctxt "Menu6"
msgid "About" msgid "About"
msgstr "" msgstr ""
#: rog-control-center/ui/main_window.slint:73 #: rog-control-center/ui/main_window.slint:74
msgctxt "MainWindow" msgctxt "MainWindow"
msgid "Quit App" msgid "Quit App"
msgstr "" msgstr ""
+1
View File
@@ -19,6 +19,7 @@ export { AppSize, AttrMinMax, SystemPageData, AnimePageData, AppSettingsPageData
export component MainWindow inherits Window { export component MainWindow inherits Window {
title: "ROG Control"; title: "ROG Control";
always-on-top: true;
default-font-family: "Noto Sans"; default-font-family: "Noto Sans";
default-font-size: 14px; default-font-size: 14px;
default-font-weight: 400; default-font-weight: 400;
+43 -35
View File
@@ -4,12 +4,12 @@ import { Palette, HorizontalBox , VerticalBox, ScrollView, Slider, Button, Switc
export struct AttrMinMax { export struct AttrMinMax {
min: int, min: int,
max: int, max: int,
val: float, current: float,
} }
export struct AttrPossible { export struct AttrPossible {
range: [int], range: [int],
val: int, current: int,
} }
export global SystemPageData { export global SystemPageData {
@@ -54,7 +54,7 @@ export global SystemPageData {
in-out property <AttrMinMax> ppt_pl1_spl: { in-out property <AttrMinMax> ppt_pl1_spl: {
min: 0, min: 0,
max: 100, max: 100,
val: 20, current: 20,
}; };
callback cb_ppt_pl1_spl(int); callback cb_ppt_pl1_spl(int);
callback cb_default_ppt_pl1_spl(); callback cb_default_ppt_pl1_spl();
@@ -62,7 +62,7 @@ export global SystemPageData {
in-out property <AttrMinMax> ppt_pl2_sppt: { in-out property <AttrMinMax> ppt_pl2_sppt: {
min: 0, min: 0,
max: 100, max: 100,
val: 20, current: 20,
}; };
callback cb_ppt_pl2_sppt(int); callback cb_ppt_pl2_sppt(int);
callback cb_default_ppt_pl2_sppt(); callback cb_default_ppt_pl2_sppt();
@@ -70,7 +70,7 @@ export global SystemPageData {
in-out property <AttrMinMax> ppt_pl3_fppt: { in-out property <AttrMinMax> ppt_pl3_fppt: {
min: 0, min: 0,
max: 100, max: 100,
val: 20, current: 20,
}; };
callback cb_ppt_pl3_fppt(int); callback cb_ppt_pl3_fppt(int);
callback cb_default_ppt_pl3_fppt(); callback cb_default_ppt_pl3_fppt();
@@ -78,7 +78,7 @@ export global SystemPageData {
in-out property <AttrMinMax> ppt_fppt: { in-out property <AttrMinMax> ppt_fppt: {
min: 0, min: 0,
max: 100, max: 100,
val: 20, current: 20,
}; };
callback cb_ppt_fppt(int); callback cb_ppt_fppt(int);
callback cb_default_ppt_fppt(); callback cb_default_ppt_fppt();
@@ -86,7 +86,7 @@ export global SystemPageData {
in-out property <AttrMinMax> ppt_apu_sppt: { in-out property <AttrMinMax> ppt_apu_sppt: {
min: 0, min: 0,
max: 100, max: 100,
val: 20, current: 20,
}; };
callback cb_ppt_apu_sppt(int); callback cb_ppt_apu_sppt(int);
callback cb_default_ppt_apu_sppt(); callback cb_default_ppt_apu_sppt();
@@ -94,7 +94,7 @@ export global SystemPageData {
in-out property <AttrMinMax> ppt_platform_sppt: { in-out property <AttrMinMax> ppt_platform_sppt: {
min: 0, min: 0,
max: 100, max: 100,
val: 20, current: 20,
}; };
callback cb_ppt_platform_sppt(int); callback cb_ppt_platform_sppt(int);
callback cb_default_ppt_platform_sppt(); callback cb_default_ppt_platform_sppt();
@@ -102,7 +102,7 @@ export global SystemPageData {
in-out property <AttrMinMax> nv_dynamic_boost: { in-out property <AttrMinMax> nv_dynamic_boost: {
min: 0, min: 0,
max: 30, max: 30,
val: 5, current: 5,
}; };
callback cb_nv_dynamic_boost(int); callback cb_nv_dynamic_boost(int);
callback cb_default_nv_dynamic_boost(); callback cb_default_nv_dynamic_boost();
@@ -110,7 +110,7 @@ export global SystemPageData {
in-out property <AttrMinMax> nv_temp_target: { in-out property <AttrMinMax> nv_temp_target: {
min: 0, min: 0,
max: 80, max: 80,
val: 75, current: 75,
}; };
callback cb_nv_temp_target(int); callback cb_nv_temp_target(int);
callback cb_default_nv_temp_target(); callback cb_default_nv_temp_target();
@@ -237,7 +237,7 @@ export component PageSystem inherits Rectangle {
} }
} }
if SystemPageData.ppt_pl1_spl.val != -1 || SystemPageData.ppt_pl2_sppt.val != -1 || SystemPageData.nv_dynamic_boost.val != -1: HorizontalLayout { if SystemPageData.ppt_pl1_spl.current != -1 || SystemPageData.ppt_pl2_sppt.current != -1 || SystemPageData.nv_dynamic_boost.current != -1: HorizontalLayout {
padding-right: 10px; padding-right: 10px;
padding-left: 10px; padding-left: 10px;
alignment: LayoutAlignment.space-between; alignment: LayoutAlignment.space-between;
@@ -258,137 +258,145 @@ export component PageSystem inherits Rectangle {
} }
} }
if SystemPageData.ppt_pl1_spl.val != -1: SystemSlider { if SystemPageData.ppt_pl1_spl.current != -1: SystemSlider {
text: @tr("ppt_pl1_spl" => "CPU Sustained Power Limit"); text: @tr("ppt_pl1_spl" => "CPU Sustained Power Limit");
title: @tr("ppt_pl1_spl" => "CPU Sustained Power Limit"); title: @tr("ppt_pl1_spl" => "CPU Sustained Power Limit");
help_text: @tr("ppt_pl1_spl_help" => "Long-term CPU power limit that affects sustained workload performance. Higher values may increase heat and power consumption."); help_text: @tr("ppt_pl1_spl_help" => "Long-term CPU power limit that affects sustained workload performance. Higher values may increase heat and power consumption.");
minimum: SystemPageData.ppt_pl1_spl.min; minimum: SystemPageData.ppt_pl1_spl.min;
maximum: SystemPageData.ppt_pl1_spl.max; maximum: SystemPageData.ppt_pl1_spl.max;
value: SystemPageData.ppt_pl1_spl.val; value: SystemPageData.ppt_pl1_spl.current;
enabled <=> SystemPageData.enable_ppt_group;
has_reset: true; has_reset: true;
cb_do_reset => { cb_do_reset => {
SystemPageData.cb_default_ppt_pl1_spl(); SystemPageData.cb_default_ppt_pl1_spl();
} }
released => { released => {
SystemPageData.ppt_pl1_spl.val = self.value; SystemPageData.ppt_pl1_spl.current = self.value;
SystemPageData.cb_ppt_pl1_spl(Math.round(self.value)); SystemPageData.cb_ppt_pl1_spl(Math.round(self.value));
} }
} }
if SystemPageData.ppt_pl2_sppt.val != -1: SystemSlider { if SystemPageData.ppt_pl2_sppt.current != -1: SystemSlider {
text: @tr("ppt_pl2_sppt" => "CPU Turbo Power Limit"); text: @tr("ppt_pl2_sppt" => "CPU Turbo Power Limit");
title: @tr("ppt_pl2_sppt" => "CPU Turbo Power Limit"); title: @tr("ppt_pl2_sppt" => "CPU Turbo Power Limit");
help_text: @tr("ppt_pl2_sppt_help" => "Short-term CPU power limit for boost periods. Controls maximum power during brief high-performance bursts."); help_text: @tr("ppt_pl2_sppt_help" => "Short-term CPU power limit for boost periods. Controls maximum power during brief high-performance bursts.");
minimum: SystemPageData.ppt_pl2_sppt.min; minimum: SystemPageData.ppt_pl2_sppt.min;
maximum: SystemPageData.ppt_pl2_sppt.max; maximum: SystemPageData.ppt_pl2_sppt.max;
value: SystemPageData.ppt_pl2_sppt.val; value: SystemPageData.ppt_pl2_sppt.current;
enabled <=> SystemPageData.enable_ppt_group;
has_reset: true; has_reset: true;
cb_do_reset => { cb_do_reset => {
SystemPageData.cb_default_ppt_pl2_sppt(); SystemPageData.cb_default_ppt_pl2_sppt();
} }
released => { released => {
SystemPageData.ppt_pl2_sppt.val = self.value; SystemPageData.ppt_pl2_sppt.current = self.value;
SystemPageData.cb_ppt_pl2_sppt(Math.round(self.value)) SystemPageData.cb_ppt_pl2_sppt(Math.round(self.value))
} }
} }
if SystemPageData.ppt_pl3_fppt.val != -1: SystemSlider { if SystemPageData.ppt_pl3_fppt.current != -1: SystemSlider {
text: @tr("ppt_pl3_fppt" => "CPU Fast Burst Power Limit"); text: @tr("ppt_pl3_fppt" => "CPU Fast Burst Power Limit");
title: @tr("ppt_pl3_fppt" => "CPU Fast Burst Power Limit"); title: @tr("ppt_pl3_fppt" => "CPU Fast Burst Power Limit");
help_text: @tr("ppt_pl3_fppt_help" => "Ultra-short duration power limit for instantaneous CPU bursts. Affects responsiveness during sudden workload spikes."); help_text: @tr("ppt_pl3_fppt_help" => "Ultra-short duration power limit for instantaneous CPU bursts. Affects responsiveness during sudden workload spikes.");
minimum: SystemPageData.ppt_pl3_fppt.min; minimum: SystemPageData.ppt_pl3_fppt.min;
maximum: SystemPageData.ppt_pl3_fppt.max; maximum: SystemPageData.ppt_pl3_fppt.max;
value: SystemPageData.ppt_pl3_fppt.val; value: SystemPageData.ppt_pl3_fppt.current;
enabled <=> SystemPageData.enable_ppt_group;
has_reset: true; has_reset: true;
cb_do_reset => { cb_do_reset => {
SystemPageData.cb_default_ppt_pl3_fppt(); SystemPageData.cb_default_ppt_pl3_fppt();
} }
released => { released => {
SystemPageData.ppt_pl3_fppt.val = self.value; SystemPageData.ppt_pl3_fppt.current = self.value;
SystemPageData.cb_ppt_pl3_fppt(Math.round(self.value)) SystemPageData.cb_ppt_pl3_fppt(Math.round(self.value))
} }
} }
if SystemPageData.ppt_fppt.val != -1: SystemSlider { if SystemPageData.ppt_fppt.current != -1: SystemSlider {
text: @tr("ppt_fppt" => "Fast Package Power Limit"); text: @tr("ppt_fppt" => "Fast Package Power Limit");
title: @tr("ppt_fppt" => "Fast Package Power Limit"); title: @tr("ppt_fppt" => "Fast Package Power Limit");
help_text: @tr("ppt_fppt_help" => "Ultra-short duration power limit for system package. Controls maximum power during millisecond-scale load spikes."); help_text: @tr("ppt_fppt_help" => "Ultra-short duration power limit for system package. Controls maximum power during millisecond-scale load spikes.");
minimum: SystemPageData.ppt_fppt.min; minimum: SystemPageData.ppt_fppt.min;
maximum: SystemPageData.ppt_fppt.max; maximum: SystemPageData.ppt_fppt.max;
value: SystemPageData.ppt_fppt.val; value: SystemPageData.ppt_fppt.current;
enabled <=> SystemPageData.enable_ppt_group;
has_reset: true; has_reset: true;
cb_do_reset => { cb_do_reset => {
SystemPageData.cb_default_ppt_fppt(); SystemPageData.cb_default_ppt_fppt();
} }
released => { released => {
SystemPageData.ppt_fppt.val = self.value; SystemPageData.ppt_fppt.current = self.value;
SystemPageData.cb_ppt_fppt(Math.round(self.value)) SystemPageData.cb_ppt_fppt(Math.round(self.value))
} }
} }
if SystemPageData.ppt_apu_sppt.val != -1: SystemSlider { if SystemPageData.ppt_apu_sppt.current != -1: SystemSlider {
text: @tr("ppt_apu_sppt" => "APU Sustained Power Limit"); text: @tr("ppt_apu_sppt" => "APU Sustained Power Limit");
title: @tr("ppt_apu_sppt" => "APU Sustained Power Limit"); title: @tr("ppt_apu_sppt" => "APU Sustained Power Limit");
help_text: @tr("ppt_apu_sppt_help" => "Long-term power limit for integrated graphics and CPU combined. Affects sustained performance of APU-based workloads."); help_text: @tr("ppt_apu_sppt_help" => "Long-term power limit for integrated graphics and CPU combined. Affects sustained performance of APU-based workloads.");
minimum: SystemPageData.ppt_apu_sppt.min; minimum: SystemPageData.ppt_apu_sppt.min;
maximum: SystemPageData.ppt_apu_sppt.max; maximum: SystemPageData.ppt_apu_sppt.max;
value: SystemPageData.ppt_apu_sppt.val; value: SystemPageData.ppt_apu_sppt.current;
enabled <=> SystemPageData.enable_ppt_group;
has_reset: true; has_reset: true;
cb_do_reset => { cb_do_reset => {
SystemPageData.cb_default_ppt_apu_sppt(); SystemPageData.cb_default_ppt_apu_sppt();
} }
released => { released => {
SystemPageData.ppt_apu_sppt.val = self.value; SystemPageData.ppt_apu_sppt.current = self.value;
SystemPageData.cb_ppt_apu_sppt(Math.round(self.value)) SystemPageData.cb_ppt_apu_sppt(Math.round(self.value))
} }
} }
if SystemPageData.ppt_platform_sppt.val != -1: SystemSlider { if SystemPageData.ppt_platform_sppt.current != -1: SystemSlider {
text: @tr("ppt_platform_sppt" => "Platform Sustained Power Limit"); text: @tr("ppt_platform_sppt" => "Platform Sustained Power Limit");
title: @tr("ppt_platform_sppt" => "Platform Sustained Power Limit"); title: @tr("ppt_platform_sppt" => "Platform Sustained Power Limit");
help_text: @tr("ppt_platform_sppt_help" => "Overall system power limit for sustained operations. Controls total platform power consumption over extended periods."); help_text: @tr("ppt_platform_sppt_help" => "Overall system power limit for sustained operations. Controls total platform power consumption over extended periods.");
minimum: SystemPageData.ppt_platform_sppt.min; minimum: SystemPageData.ppt_platform_sppt.min;
maximum: SystemPageData.ppt_platform_sppt.max; maximum: SystemPageData.ppt_platform_sppt.max;
value: SystemPageData.ppt_platform_sppt.val; value: SystemPageData.ppt_platform_sppt.current;
enabled <=> SystemPageData.enable_ppt_group;
has_reset: true; has_reset: true;
cb_do_reset => { cb_do_reset => {
SystemPageData.cb_default_ppt_platform_sppt(); SystemPageData.cb_default_ppt_platform_sppt();
} }
released => { released => {
SystemPageData.ppt_platform_sppt.val = self.value; SystemPageData.ppt_platform_sppt.current = self.value;
SystemPageData.cb_ppt_platform_sppt(Math.round(self.value)) SystemPageData.cb_ppt_platform_sppt(Math.round(self.value))
} }
} }
if SystemPageData.nv_dynamic_boost.val != -1: SystemSlider { if SystemPageData.nv_dynamic_boost.current != -1: SystemSlider {
text: @tr("nv_dynamic_boost" => "GPU Power Boost"); text: @tr("nv_dynamic_boost" => "GPU Power Boost");
title: @tr("nv_dynamic_boost" => "GPU Power Boost"); title: @tr("nv_dynamic_boost" => "GPU Power Boost");
help_text: @tr("nv_dynamic_boost_help" => "Additional power allocation for GPU dynamic boost. Higher values increase GPU performance but generate more heat."); help_text: @tr("nv_dynamic_boost_help" => "Additional power allocation for GPU dynamic boost. Higher values increase GPU performance but generate more heat.");
minimum: SystemPageData.nv_dynamic_boost.min; minimum: SystemPageData.nv_dynamic_boost.min;
maximum: SystemPageData.nv_dynamic_boost.max; maximum: SystemPageData.nv_dynamic_boost.max;
value: SystemPageData.nv_dynamic_boost.val; value: SystemPageData.nv_dynamic_boost.current;
enabled <=> SystemPageData.enable_ppt_group;
has_reset: true; has_reset: true;
cb_do_reset => { cb_do_reset => {
SystemPageData.cb_default_nv_dynamic_boost(); SystemPageData.cb_default_nv_dynamic_boost();
} }
released => { released => {
SystemPageData.nv_dynamic_boost.val = self.value; SystemPageData.nv_dynamic_boost.current = self.value;
SystemPageData.cb_nv_dynamic_boost(Math.round(self.value)) SystemPageData.cb_nv_dynamic_boost(Math.round(self.value))
} }
} }
if SystemPageData.nv_temp_target.val != -1: SystemSlider { if SystemPageData.nv_temp_target.current != -1: SystemSlider {
text: @tr("nv_temp_target" => "GPU Temperature Limit"); text: @tr("nv_temp_target" => "GPU Temperature Limit");
title: @tr("nv_temp_target" => "GPU Temperature Limit"); title: @tr("nv_temp_target" => "GPU Temperature Limit");
help_text: @tr("nv_temp_target_help" => "Maximum GPU temperature threshold in Celsius. GPU will throttle to maintain temperature below this limit."); help_text: @tr("nv_temp_target_help" => "Maximum GPU temperature threshold in Celsius. GPU will throttle to maintain temperature below this limit.");
minimum: SystemPageData.nv_temp_target.min; minimum: SystemPageData.nv_temp_target.min;
maximum: SystemPageData.nv_temp_target.max; maximum: SystemPageData.nv_temp_target.max;
value: SystemPageData.nv_temp_target.val; value: SystemPageData.nv_temp_target.current;
enabled <=> SystemPageData.enable_ppt_group;
has_reset: true; has_reset: true;
cb_do_reset => { cb_do_reset => {
SystemPageData.cb_default_nv_temp_target(); SystemPageData.cb_default_nv_temp_target();
} }
released => { released => {
SystemPageData.nv_temp_target.val = self.value; SystemPageData.nv_temp_target.current = self.value;
SystemPageData.cb_nv_temp_target(Math.round(self.value)) SystemPageData.cb_nv_temp_target(Math.round(self.value))
} }
} }
@@ -12,6 +12,7 @@ export component RogItem inherits Rectangle {
export component SystemSlider inherits RogItem { export component SystemSlider inherits RogItem {
in property <string> title; in property <string> title;
in property <string> text; in property <string> text;
in-out property <bool> enabled;
in-out property <float> value; in-out property <float> value;
in-out property <float> minimum; in-out property <float> minimum;
in-out property <float> maximum; in-out property <float> maximum;
@@ -27,6 +28,7 @@ export component SystemSlider inherits RogItem {
alignment: LayoutAlignment.stretch; alignment: LayoutAlignment.stretch;
padding-left: 10px; padding-left: 10px;
TouchArea { TouchArea {
enabled <=> root.enabled;
clicked => { clicked => {
slider.value += 1; slider.value += 1;
if slider.value > slider.maximum { if slider.value > slider.maximum {
@@ -57,6 +59,7 @@ export component SystemSlider inherits RogItem {
// alignment: LayoutAlignment.end; // alignment: LayoutAlignment.end;
padding-right: 20px; padding-right: 20px;
slider := Slider { slider := Slider {
enabled <=> root.enabled;
maximum: root.maximum; maximum: root.maximum;
minimum: root.minimum; minimum: root.minimum;
value <=> root.value; value <=> root.value;
@@ -150,6 +153,7 @@ export component SystemSlider inherits RogItem {
reset := HorizontalBox { reset := HorizontalBox {
if (has_reset): StandardButton { if (has_reset): StandardButton {
kind: StandardButtonKind.reset; kind: StandardButtonKind.reset;
enabled <=> root.enabled;
clicked => { clicked => {
reset_popup.show(); reset_popup.show();
} }
+10 -4
View File
@@ -172,8 +172,8 @@ impl Attribute {
) )
} }
pub fn get_watcher(&self) -> Result<inotify::Inotify, PlatformError> { pub fn get_watcher(&self, attr: &str) -> Result<inotify::Inotify, PlatformError> {
let path = self.base_path.join("current_value"); let path = self.base_path.join(attr);
if let Some(path) = path.to_str() { if let Some(path) = path.to_str() {
let inotify = inotify::Inotify::init()?; let inotify = inotify::Inotify::init()?;
inotify inotify
@@ -317,7 +317,13 @@ impl FirmwareAttribute {
| FirmwareAttribute::PptFppt | FirmwareAttribute::PptFppt
| FirmwareAttribute::PptApuSppt | FirmwareAttribute::PptApuSppt
| FirmwareAttribute::PptPlatformSppt | FirmwareAttribute::PptPlatformSppt
| FirmwareAttribute::NvDynamicBoost )
}
pub fn is_dgpu(&self) -> bool {
matches!(
self,
FirmwareAttribute::NvDynamicBoost
| FirmwareAttribute::NvTempTarget | FirmwareAttribute::NvTempTarget
| FirmwareAttribute::DgpuTgp | FirmwareAttribute::DgpuTgp
) )
@@ -338,7 +344,7 @@ impl From<&str> for FirmwareAttribute {
"ppt_platform_sppt" => Self::PptPlatformSppt, "ppt_platform_sppt" => Self::PptPlatformSppt,
"nv_dynamic_boost" => Self::NvDynamicBoost, "nv_dynamic_boost" => Self::NvDynamicBoost,
"nv_temp_target" => Self::NvTempTarget, "nv_temp_target" => Self::NvTempTarget,
"dgpu_base_tgp" => Self::DgpuBaseTgp, "nv_base_tgp" => Self::DgpuBaseTgp,
"dgpu_tgp" => Self::DgpuTgp, "dgpu_tgp" => Self::DgpuTgp,
"charge_mode" => Self::ChargeMode, "charge_mode" => Self::ChargeMode,
"boot_sound" => Self::BootSound, "boot_sound" => Self::BootSound,