mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Adjust how thread exit is handled for anime controller
This commit is contained in:
@@ -83,7 +83,6 @@ impl AuraConfigV407 {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub struct AuraConfig {
|
||||
pub brightness: LedBrightness,
|
||||
@@ -94,7 +93,7 @@ pub struct AuraConfig {
|
||||
pub sleep_anim_enabled: bool,
|
||||
pub all_leds_enabled: bool,
|
||||
pub keys_leds_enabled: bool,
|
||||
pub side_leds_enabled: bool
|
||||
pub side_leds_enabled: bool,
|
||||
}
|
||||
|
||||
impl Default for AuraConfig {
|
||||
|
||||
@@ -9,10 +9,9 @@ use crate::{
|
||||
use async_trait::async_trait;
|
||||
use log::{error, info, warn};
|
||||
use logind_zbus::manager::ManagerProxy;
|
||||
use rog_aura::usb::leds_message;
|
||||
use rog_aura::{
|
||||
usb::{
|
||||
LED_APPLY, LED_SET
|
||||
},
|
||||
usb::{LED_APPLY, LED_SET},
|
||||
AuraEffect, LedBrightness, LED_MSG_LEN,
|
||||
};
|
||||
use rog_supported::LedSupportedFunctions;
|
||||
@@ -23,14 +22,11 @@ use std::path::Path;
|
||||
use std::sync::Arc;
|
||||
use std::sync::Mutex;
|
||||
use zbus::Connection;
|
||||
use rog_aura::usb::leds_message;
|
||||
|
||||
use crate::GetSupported;
|
||||
|
||||
use super::config::AuraConfig;
|
||||
|
||||
|
||||
|
||||
impl GetSupported for CtrlKbdLed {
|
||||
type A = LedSupportedFunctions;
|
||||
|
||||
@@ -281,20 +277,19 @@ impl CtrlKbdLed {
|
||||
self.set_brightness(self.config.brightness)
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// Set combination state for boot animation/sleep animation/all leds/keys leds/side leds LED active
|
||||
pub(super) fn set_power_states(&self, config: &AuraConfig) -> Result<(), RogError> {
|
||||
|
||||
let bytes = leds_message(config.boot_anim_enabled,
|
||||
config.sleep_anim_enabled,
|
||||
config.all_leds_enabled,
|
||||
config.keys_leds_enabled,
|
||||
config.side_leds_enabled);
|
||||
let bytes = leds_message(
|
||||
config.boot_anim_enabled,
|
||||
config.sleep_anim_enabled,
|
||||
config.all_leds_enabled,
|
||||
config.keys_leds_enabled,
|
||||
config.side_leds_enabled,
|
||||
);
|
||||
|
||||
// Quite ugly, must be a more idiomatic way to do
|
||||
let message = [
|
||||
0x5d, 0xbd, 0x01, bytes[0], bytes[1], bytes[2], 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
0x5d, 0xbd, 0x01, bytes[0], bytes[1], bytes[2], 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
];
|
||||
|
||||
self.write_bytes(&message)?;
|
||||
|
||||
@@ -38,15 +38,15 @@ impl CtrlKbdLedZbus {
|
||||
ctrl.config.write();
|
||||
|
||||
ctrl.set_power_states(&ctrl.config)
|
||||
.map_err(|err| warn!("{}", err))
|
||||
.ok();
|
||||
.map_err(|err| warn!("{}", err))
|
||||
.ok();
|
||||
|
||||
states = Some(LedPowerStates {
|
||||
boot_anim: ctrl.config.boot_anim_enabled,
|
||||
sleep_anim: ctrl.config.sleep_anim_enabled,
|
||||
all_leds: ctrl.config.all_leds_enabled,
|
||||
keys_leds: ctrl.config.keys_leds_enabled,
|
||||
side_leds: ctrl.config.side_leds_enabled
|
||||
side_leds: ctrl.config.side_leds_enabled,
|
||||
});
|
||||
}
|
||||
// Need to pull state out like this due to MutexGuard
|
||||
@@ -69,15 +69,15 @@ impl CtrlKbdLedZbus {
|
||||
ctrl.config.write();
|
||||
|
||||
ctrl.set_power_states(&ctrl.config)
|
||||
.map_err(|err| warn!("{}", err))
|
||||
.ok();
|
||||
.map_err(|err| warn!("{}", err))
|
||||
.ok();
|
||||
|
||||
states = Some(LedPowerStates {
|
||||
boot_anim: ctrl.config.boot_anim_enabled,
|
||||
sleep_anim: ctrl.config.sleep_anim_enabled,
|
||||
all_leds: ctrl.config.all_leds_enabled,
|
||||
keys_leds: ctrl.config.keys_leds_enabled,
|
||||
side_leds: ctrl.config.side_leds_enabled
|
||||
side_leds: ctrl.config.side_leds_enabled,
|
||||
});
|
||||
}
|
||||
if let Some(states) = states {
|
||||
@@ -109,7 +109,7 @@ impl CtrlKbdLedZbus {
|
||||
sleep_anim: ctrl.config.sleep_anim_enabled,
|
||||
all_leds: ctrl.config.all_leds_enabled,
|
||||
keys_leds: ctrl.config.keys_leds_enabled,
|
||||
side_leds: ctrl.config.side_leds_enabled
|
||||
side_leds: ctrl.config.side_leds_enabled,
|
||||
});
|
||||
}
|
||||
// Need to pull state out like this due to MutexGuard
|
||||
@@ -140,7 +140,7 @@ impl CtrlKbdLedZbus {
|
||||
sleep_anim: ctrl.config.sleep_anim_enabled,
|
||||
all_leds: ctrl.config.all_leds_enabled,
|
||||
keys_leds: ctrl.config.keys_leds_enabled,
|
||||
side_leds: ctrl.config.side_leds_enabled
|
||||
side_leds: ctrl.config.side_leds_enabled,
|
||||
});
|
||||
}
|
||||
// Need to pull state out like this due to MutexGuard
|
||||
@@ -171,7 +171,7 @@ impl CtrlKbdLedZbus {
|
||||
sleep_anim: ctrl.config.sleep_anim_enabled,
|
||||
all_leds: ctrl.config.all_leds_enabled,
|
||||
keys_leds: ctrl.config.keys_leds_enabled,
|
||||
side_leds: ctrl.config.side_leds_enabled
|
||||
side_leds: ctrl.config.side_leds_enabled,
|
||||
});
|
||||
}
|
||||
// Need to pull state out like this due to MutexGuard
|
||||
|
||||
Reference in New Issue
Block a user