mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
wip: reload current settings in rogcc for LEDs
This commit is contained in:
@@ -33,7 +33,6 @@ pub struct AuraConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl StdConfig for AuraConfig {
|
impl StdConfig for AuraConfig {
|
||||||
/// Detect the keyboard type and load from default DB if data available
|
|
||||||
fn new() -> Self {
|
fn new() -> Self {
|
||||||
panic!("This should not be used");
|
panic!("This should not be used");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -182,7 +182,6 @@ impl AuraZbus {
|
|||||||
self.0.set_brightness(config.brightness.into()).await?;
|
self.0.set_brightness(config.brightness.into()).await?;
|
||||||
config.set_builtin(effect);
|
config.set_builtin(effect);
|
||||||
config.write();
|
config.write();
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -208,9 +207,10 @@ impl AuraZbus {
|
|||||||
let mut config = self.0.config.lock().await;
|
let mut config = self.0.config.lock().await;
|
||||||
for opt in options.states {
|
for opt in options.states {
|
||||||
let zone = opt.zone;
|
let zone = opt.zone;
|
||||||
for config in config.enabled.states.iter_mut() {
|
for state in config.enabled.states.iter_mut() {
|
||||||
if config.zone == zone {
|
if state.zone == zone {
|
||||||
*config = opt;
|
*state = opt;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -196,6 +196,7 @@ impl DeviceHandle {
|
|||||||
Some(Arc::new(Mutex::new(k)))
|
Some(Arc::new(Mutex::new(k)))
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Load saved mode, colours, brightness, power from disk; apply on reload
|
||||||
let mut config = AuraConfig::load_and_update_config(prod_id);
|
let mut config = AuraConfig::load_and_update_config(prod_id);
|
||||||
config.led_type = aura_type;
|
config.led_type = aura_type;
|
||||||
let aura = Aura {
|
let aura = Aura {
|
||||||
|
|||||||
@@ -83,15 +83,6 @@ pub fn setup_aura_page(
|
|||||||
set_ui_props_async!(handle, aura, AuraPageData, led_power);
|
set_ui_props_async!(handle, aura, AuraPageData, led_power);
|
||||||
set_ui_props_async!(handle, aura, AuraPageData, device_type);
|
set_ui_props_async!(handle, aura, AuraPageData, device_type);
|
||||||
|
|
||||||
if let Ok(data) = aura.led_mode_data().await {
|
|
||||||
let d = data.into();
|
|
||||||
handle
|
|
||||||
.upgrade_in_event_loop(move |h| {
|
|
||||||
h.global::<AuraPageData>().invoke_update_led_mode_data(d);
|
|
||||||
})
|
|
||||||
.ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
let modes_vec: Vec<i32> = match prefetched_supported {
|
let modes_vec: Vec<i32> = match prefetched_supported {
|
||||||
Some(p) => p,
|
Some(p) => p,
|
||||||
None => aura
|
None => aura
|
||||||
@@ -101,11 +92,15 @@ pub fn setup_aura_page(
|
|||||||
.map(|m| m.iter().map(|n| (*n).into()).collect())
|
.map(|m| m.iter().map(|n| (*n).into()).collect())
|
||||||
.unwrap_or_default(),
|
.unwrap_or_default(),
|
||||||
};
|
};
|
||||||
let current_mode: Option<i32> = aura.led_mode().await.ok().map(|m| m.into());
|
|
||||||
|
|
||||||
|
// Restore saved mode, colours, zone, speed, direction from asusd (persisted to disk).
|
||||||
|
// Use effect.mode as single source — avoid led_mode() which can fail (try_lock).
|
||||||
|
let restore = aura.led_mode_data().await.ok();
|
||||||
|
let raw_mode: Option<i32> = restore.as_ref().map(|d| d.mode.into());
|
||||||
|
let d_slint = restore.map(|d| d.into());
|
||||||
handle
|
handle
|
||||||
.upgrade_in_event_loop(move |handle| {
|
.upgrade_in_event_loop(move |h| {
|
||||||
let names = handle.global::<AuraPageData>().get_mode_names();
|
let names = h.global::<AuraPageData>().get_mode_names();
|
||||||
let mut raws = Vec::new();
|
let mut raws = Vec::new();
|
||||||
let mut mode_names = Vec::new();
|
let mut mode_names = Vec::new();
|
||||||
for (i, name) in names.iter().enumerate() {
|
for (i, name) in names.iter().enumerate() {
|
||||||
@@ -115,17 +110,17 @@ pub fn setup_aura_page(
|
|||||||
mode_names.push(name.clone());
|
mode_names.push(name.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
handle
|
h.global::<AuraPageData>()
|
||||||
.global::<AuraPageData>()
|
|
||||||
.set_supported_basic_modes(raws.as_slice().into());
|
.set_supported_basic_modes(raws.as_slice().into());
|
||||||
handle
|
h.global::<AuraPageData>()
|
||||||
.global::<AuraPageData>()
|
|
||||||
.set_available_mode_names(mode_names.as_slice().into());
|
.set_available_mode_names(mode_names.as_slice().into());
|
||||||
if let Some(cm) = current_mode {
|
if let Some(d) = d_slint {
|
||||||
let idx = raws.iter().position(|&r| r == cm).unwrap_or(0) as i32;
|
h.global::<AuraPageData>().invoke_update_led_mode_data(d);
|
||||||
handle
|
if let Some(cm) = raw_mode {
|
||||||
.global::<AuraPageData>()
|
let idx = raws.iter().position(|&r| r == cm).unwrap_or(0) as i32;
|
||||||
.set_current_available_mode(idx);
|
h.global::<AuraPageData>().set_current_available_mode(idx);
|
||||||
|
}
|
||||||
|
h.invoke_external_colour_change();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.map_err(|e| error!("{e}"))
|
.map_err(|e| error!("{e}"))
|
||||||
|
|||||||
Reference in New Issue
Block a user