mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-01-22 17:33:19 +01:00
Fix many small bugs in refactor of laptop LED mode handling
Closes issue #27
This commit is contained in:
4
Cargo.lock
generated
4
Cargo.lock
generated
@@ -697,7 +697,7 @@ checksum = "cabe4fa914dec5870285fa7f71f602645da47c486e68486d2b4ceb4a343e90ac"
|
||||
|
||||
[[package]]
|
||||
name = "rog-client"
|
||||
version = "0.14.0"
|
||||
version = "0.14.3"
|
||||
dependencies = [
|
||||
"dbus",
|
||||
"gumdrop",
|
||||
@@ -710,7 +710,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rog-daemon"
|
||||
version = "0.14.0"
|
||||
version = "0.14.3"
|
||||
dependencies = [
|
||||
"dbus",
|
||||
"dbus-tokio",
|
||||
|
||||
6
debian/changelog
vendored
6
debian/changelog
vendored
@@ -1,3 +1,9 @@
|
||||
rog-core (0.14.3) focal; urgency=medium
|
||||
|
||||
- Proper fix of laptop mode conversion bug
|
||||
|
||||
-- Luke Jones <luke@ljones.dev> Sun, 05 Jul 2020 21:22:05 +1200
|
||||
|
||||
rog-core (0.14.2) focal; urgency=medium
|
||||
|
||||
- Try to correct how laptop modes are handled
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "rog-client"
|
||||
version = "0.14.0"
|
||||
version = "0.14.3"
|
||||
license = "MPL-2.0"
|
||||
readme = "README.md"
|
||||
authors = ["Luke <luke@ljones.dev>"]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "rog-daemon"
|
||||
version = "0.14.0"
|
||||
version = "0.14.3"
|
||||
license = "MPL-2.0"
|
||||
readme = "README.md"
|
||||
authors = ["Luke <luke@ljones.dev>"]
|
||||
|
||||
@@ -63,7 +63,7 @@ pub async fn start_daemon() -> Result<(), Box<dyn Error>> {
|
||||
laptop.supported_modes().to_owned(),
|
||||
);
|
||||
led_writer
|
||||
.reload_last_builtin(&config)
|
||||
.reload_last_builtin(&mut config)
|
||||
.await
|
||||
.unwrap_or_else(|err| warn!("Reload settings: {}", err));
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ static LED_APPLY: [u8; 17] = [0x5d, 0xb4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
static LED_SET: [u8; 17] = [0x5d, 0xb5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
||||
|
||||
use crate::{config::Config, error::RogError};
|
||||
use log::{error, info};
|
||||
use log::{error, info, warn};
|
||||
use rog_client::{
|
||||
aura_brightness_bytes, aura_modes::AuraModes, fancy::KeyColourArray, LED_MSG_LEN,
|
||||
};
|
||||
@@ -181,17 +181,38 @@ where
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub async fn reload_last_builtin(&mut self, config: &Config) -> Result<(), RogError> {
|
||||
pub async fn reload_last_builtin(&mut self, config: &mut Config) -> Result<(), RogError> {
|
||||
self.initialise().await?;
|
||||
// set current mode (if any)
|
||||
if self.supported_modes.len() > 1 {
|
||||
let mode = config
|
||||
.get_led_mode_data(config.current_mode)
|
||||
.ok_or(RogError::NotSupported)?
|
||||
.to_owned();
|
||||
let mode: [u8; LED_MSG_LEN] = mode.into();
|
||||
self.write_bytes(&mode).await?;
|
||||
info!("Reloaded last used mode");
|
||||
if self.supported_modes.contains(&config.current_mode) {
|
||||
let mode = config
|
||||
.get_led_mode_data(config.current_mode)
|
||||
.ok_or(RogError::NotSupported)?
|
||||
.to_owned();
|
||||
self.write_mode(&mode).await?;
|
||||
info!("Reloaded last used mode");
|
||||
} else {
|
||||
warn!(
|
||||
"An unsupported mode was set: {}, reset to first mode available",
|
||||
<&str>::from(&<AuraModes>::from(config.current_mode))
|
||||
);
|
||||
for (idx, mode) in config.builtin_modes.iter_mut().enumerate() {
|
||||
if !self.supported_modes.contains(&mode.into()) {
|
||||
config.builtin_modes.remove(idx);
|
||||
config.write();
|
||||
break;
|
||||
}
|
||||
}
|
||||
config.current_mode = self.supported_modes[0];
|
||||
// TODO: do a recursive call with a boxed dyn future later
|
||||
let mode = config
|
||||
.get_led_mode_data(config.current_mode)
|
||||
.ok_or(RogError::NotSupported)?
|
||||
.to_owned();
|
||||
self.write_mode(&mode).await?;
|
||||
info!("Reloaded last used mode");
|
||||
}
|
||||
}
|
||||
|
||||
// Reload brightness
|
||||
|
||||
Reference in New Issue
Block a user