Various UI fixes

This commit is contained in:
Luke Jones
2025-02-01 20:31:09 +13:00
parent 36c34cb3dd
commit 5c2bcad7c6
12 changed files with 957 additions and 304 deletions

980
Cargo.lock generated

File diff suppressed because it is too large Load Diff

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(())
} }
} }

View File

@@ -372,6 +372,7 @@ impl CtrlPlatform {
.enabled = false; .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| {

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: "",
@@ -854,4 +863,4 @@
advanced_type: None, advanced_type: None,
power_zones: [Ally], power_zones: [Ally],
), ),
]) ])

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()

View File

@@ -84,7 +84,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 +120,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 +138,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 +156,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 +176,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 +218,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);
} }

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
} }

View File

@@ -16,7 +16,7 @@ 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>>) {
@@ -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,41 @@ 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 { dbg!(tmp.$value_type);
handle.global::<SystemPageData>().setter(tmp); concat_idents!(setter = set_, $property {
}); 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 +221,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();

View File

@@ -2,7 +2,7 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2025-01-21 06:49+0000\n" "POT-Creation-Date: 2025-02-01 07:27+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 ""

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;

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,137 @@ 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;
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;
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;
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;
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;
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;
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;
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;
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))
} }
} }

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,