mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
chore: fix formatting
This commit is contained in:
@@ -21,11 +21,14 @@ fn main() {
|
|||||||
let brightness = args[2].parse::<f32>().unwrap();
|
let brightness = args[2].parse::<f32>().unwrap();
|
||||||
let anime_type = get_anime_type();
|
let anime_type = get_anime_type();
|
||||||
let mut seq = Sequences::new(anime_type);
|
let mut seq = Sequences::new(anime_type);
|
||||||
seq.insert(0, &ActionLoader::AsusAnimation {
|
seq.insert(
|
||||||
file: path.into(),
|
0,
|
||||||
time: rog_anime::AnimTime::Infinite,
|
&ActionLoader::AsusAnimation {
|
||||||
brightness,
|
file: path.into(),
|
||||||
})
|
time: rog_anime::AnimTime::Infinite,
|
||||||
|
brightness,
|
||||||
|
},
|
||||||
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ impl crate::Reloadable for AsusArmouryAttribute {
|
|||||||
async fn reload(&mut self) -> Result<(), RogError> {
|
async fn reload(&mut self) -> Result<(), RogError> {
|
||||||
info!("Reloading {}", self.attr.name());
|
info!("Reloading {}", self.attr.name());
|
||||||
let name: FirmwareAttribute = self.attr.name().into();
|
let name: FirmwareAttribute = self.attr.name().into();
|
||||||
|
|
||||||
if name.is_ppt() {
|
if name.is_ppt() {
|
||||||
let profile: PlatformProfile = self.platform.get_platform_profile()?.into();
|
let profile: PlatformProfile = self.platform.get_platform_profile()?.into();
|
||||||
let power_plugged = self
|
let power_plugged = self
|
||||||
@@ -160,7 +160,11 @@ impl crate::Reloadable for AsusArmouryAttribute {
|
|||||||
self.attr.base_path_exists();
|
self.attr.base_path_exists();
|
||||||
e
|
e
|
||||||
})?;
|
})?;
|
||||||
info!("Restored armoury setting {} to {:?}", self.attr.name(), saved_value);
|
info!(
|
||||||
|
"Restored armoury setting {} to {:?}",
|
||||||
|
self.attr.name(),
|
||||||
|
saved_value
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -412,21 +416,19 @@ pub async fn start_attributes_zbus(
|
|||||||
match zbus::object_server::SignalEmitter::new(conn, path) {
|
match zbus::object_server::SignalEmitter::new(conn, path) {
|
||||||
Ok(sig) => {
|
Ok(sig) => {
|
||||||
if let Err(e) = attr.watch_and_notify(sig).await {
|
if let Err(e) = attr.watch_and_notify(sig).await {
|
||||||
error!(
|
error!("Failed to start watcher for '{}': {e:?}", attr.attr.name());
|
||||||
"Failed to start watcher for '{}': {e:?}",
|
|
||||||
attr.attr.name()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!("Failed to create SignalEmitter for '{}': {e:?}", attr.attr.name());
|
error!(
|
||||||
|
"Failed to create SignalEmitter for '{}': {e:?}",
|
||||||
|
attr.attr.name()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Err(e) = attr.move_to_zbus(conn).await {
|
if let Err(e) = attr.move_to_zbus(conn).await {
|
||||||
error!(
|
error!("Failed to register attribute '{attr_name}' on zbus: {e:?}");
|
||||||
"Failed to register attribute '{attr_name}' on zbus: {e:?}"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -294,26 +294,38 @@ mod tests {
|
|||||||
let res = config.multizone.unwrap();
|
let res = config.multizone.unwrap();
|
||||||
let sta = res.get(&AuraModeNum::Static).unwrap();
|
let sta = res.get(&AuraModeNum::Static).unwrap();
|
||||||
assert_eq!(sta.len(), 4);
|
assert_eq!(sta.len(), 4);
|
||||||
assert_eq!(sta[0].colour1, Colour {
|
assert_eq!(
|
||||||
r: 0xff,
|
sta[0].colour1,
|
||||||
g: 0x00,
|
Colour {
|
||||||
b: 0xff
|
r: 0xff,
|
||||||
});
|
g: 0x00,
|
||||||
assert_eq!(sta[1].colour1, Colour {
|
b: 0xff
|
||||||
r: 0x00,
|
}
|
||||||
g: 0xff,
|
);
|
||||||
b: 0xff
|
assert_eq!(
|
||||||
});
|
sta[1].colour1,
|
||||||
assert_eq!(sta[2].colour1, Colour {
|
Colour {
|
||||||
r: 0xff,
|
r: 0x00,
|
||||||
g: 0xff,
|
g: 0xff,
|
||||||
b: 0x00
|
b: 0xff
|
||||||
});
|
}
|
||||||
assert_eq!(sta[3].colour1, Colour {
|
);
|
||||||
r: 0x00,
|
assert_eq!(
|
||||||
g: 0xff,
|
sta[2].colour1,
|
||||||
b: 0x00
|
Colour {
|
||||||
});
|
r: 0xff,
|
||||||
|
g: 0xff,
|
||||||
|
b: 0x00
|
||||||
|
}
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
sta[3].colour1,
|
||||||
|
Colour {
|
||||||
|
r: 0x00,
|
||||||
|
g: 0xff,
|
||||||
|
b: 0x00
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -371,22 +383,28 @@ mod tests {
|
|||||||
|
|
||||||
assert_eq!(config.brightness, LedBrightness::Med);
|
assert_eq!(config.brightness, LedBrightness::Med);
|
||||||
assert_eq!(config.builtins.len(), 5);
|
assert_eq!(config.builtins.len(), 5);
|
||||||
assert_eq!(config.builtins.first_entry().unwrap().get(), &AuraEffect {
|
assert_eq!(
|
||||||
mode: AuraModeNum::Static,
|
config.builtins.first_entry().unwrap().get(),
|
||||||
zone: AuraZone::None,
|
&AuraEffect {
|
||||||
colour1: Colour { r: 166, g: 0, b: 0 },
|
mode: AuraModeNum::Static,
|
||||||
colour2: Colour { r: 0, g: 0, b: 0 },
|
zone: AuraZone::None,
|
||||||
speed: Speed::Med,
|
colour1: Colour { r: 166, g: 0, b: 0 },
|
||||||
direction: Direction::Right
|
colour2: Colour { r: 0, g: 0, b: 0 },
|
||||||
});
|
speed: Speed::Med,
|
||||||
|
direction: Direction::Right
|
||||||
|
}
|
||||||
|
);
|
||||||
assert_eq!(config.enabled.states.len(), 1);
|
assert_eq!(config.enabled.states.len(), 1);
|
||||||
assert_eq!(config.enabled.states[0], AuraPowerState {
|
assert_eq!(
|
||||||
zone: PowerZones::KeyboardAndLightbar,
|
config.enabled.states[0],
|
||||||
boot: true,
|
AuraPowerState {
|
||||||
awake: true,
|
zone: PowerZones::KeyboardAndLightbar,
|
||||||
sleep: true,
|
boot: true,
|
||||||
shutdown: true
|
awake: true,
|
||||||
});
|
sleep: true,
|
||||||
|
shutdown: true
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -396,21 +414,27 @@ mod tests {
|
|||||||
|
|
||||||
assert_eq!(config.brightness, LedBrightness::Med);
|
assert_eq!(config.brightness, LedBrightness::Med);
|
||||||
assert_eq!(config.builtins.len(), 12);
|
assert_eq!(config.builtins.len(), 12);
|
||||||
assert_eq!(config.builtins.first_entry().unwrap().get(), &AuraEffect {
|
assert_eq!(
|
||||||
mode: AuraModeNum::Static,
|
config.builtins.first_entry().unwrap().get(),
|
||||||
zone: AuraZone::None,
|
&AuraEffect {
|
||||||
colour1: Colour { r: 166, g: 0, b: 0 },
|
mode: AuraModeNum::Static,
|
||||||
colour2: Colour { r: 0, g: 0, b: 0 },
|
zone: AuraZone::None,
|
||||||
speed: Speed::Med,
|
colour1: Colour { r: 166, g: 0, b: 0 },
|
||||||
direction: Direction::Right
|
colour2: Colour { r: 0, g: 0, b: 0 },
|
||||||
});
|
speed: Speed::Med,
|
||||||
|
direction: Direction::Right
|
||||||
|
}
|
||||||
|
);
|
||||||
assert_eq!(config.enabled.states.len(), 4);
|
assert_eq!(config.enabled.states.len(), 4);
|
||||||
assert_eq!(config.enabled.states[0], AuraPowerState {
|
assert_eq!(
|
||||||
zone: PowerZones::Keyboard,
|
config.enabled.states[0],
|
||||||
boot: true,
|
AuraPowerState {
|
||||||
awake: true,
|
zone: PowerZones::Keyboard,
|
||||||
sleep: true,
|
boot: true,
|
||||||
shutdown: true
|
awake: true,
|
||||||
});
|
sleep: true,
|
||||||
|
shutdown: true
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -207,12 +207,14 @@ mod tests {
|
|||||||
fn single_key_next_state_then_create() {
|
fn single_key_next_state_then_create() {
|
||||||
let layout = KeyLayout::default_layout();
|
let layout = KeyLayout::default_layout();
|
||||||
let mut seq = AdvancedEffects::new(false);
|
let mut seq = AdvancedEffects::new(false);
|
||||||
seq.effects
|
seq.effects.push(Effect::Static(Static::new(
|
||||||
.push(Effect::Static(Static::new(LedCode::F, Colour {
|
LedCode::F,
|
||||||
|
Colour {
|
||||||
r: 255,
|
r: 255,
|
||||||
g: 127,
|
g: 127,
|
||||||
b: 0,
|
b: 0,
|
||||||
})));
|
},
|
||||||
|
)));
|
||||||
|
|
||||||
seq.next_state(&layout);
|
seq.next_state(&layout);
|
||||||
let packets = seq.create_packets();
|
let packets = seq.create_packets();
|
||||||
|
|||||||
@@ -335,93 +335,117 @@ impl KeyLayout {
|
|||||||
KeyShape::new_led(1.0, 1.0, 0.1, 0.1, 0.1, 0.1),
|
KeyShape::new_led(1.0, 1.0, 0.1, 0.1, 0.1, 0.1),
|
||||||
)]),
|
)]),
|
||||||
key_rows: vec![
|
key_rows: vec![
|
||||||
KeyRow::new(0.1, 0.1, vec![
|
KeyRow::new(
|
||||||
(LedCode::Esc, "regular".to_owned()),
|
0.1,
|
||||||
(LedCode::F1, "regular".to_owned()),
|
0.1,
|
||||||
(LedCode::F2, "regular".to_owned()),
|
vec![
|
||||||
(LedCode::F3, "regular".to_owned()),
|
(LedCode::Esc, "regular".to_owned()),
|
||||||
(LedCode::F4, "regular".to_owned()),
|
(LedCode::F1, "regular".to_owned()),
|
||||||
// not sure which key to put here
|
(LedCode::F2, "regular".to_owned()),
|
||||||
(LedCode::F5, "regular".to_owned()),
|
(LedCode::F3, "regular".to_owned()),
|
||||||
(LedCode::F6, "regular".to_owned()),
|
(LedCode::F4, "regular".to_owned()),
|
||||||
(LedCode::F7, "regular".to_owned()),
|
// not sure which key to put here
|
||||||
(LedCode::F8, "regular".to_owned()),
|
(LedCode::F5, "regular".to_owned()),
|
||||||
(LedCode::F9, "regular".to_owned()),
|
(LedCode::F6, "regular".to_owned()),
|
||||||
(LedCode::F10, "regular".to_owned()),
|
(LedCode::F7, "regular".to_owned()),
|
||||||
(LedCode::F11, "regular".to_owned()),
|
(LedCode::F8, "regular".to_owned()),
|
||||||
(LedCode::F12, "regular".to_owned()),
|
(LedCode::F9, "regular".to_owned()),
|
||||||
]),
|
(LedCode::F10, "regular".to_owned()),
|
||||||
KeyRow::new(0.1, 0.1, vec![
|
(LedCode::F11, "regular".to_owned()),
|
||||||
(LedCode::Tilde, "regular".to_owned()),
|
(LedCode::F12, "regular".to_owned()),
|
||||||
(LedCode::N1, "regular".to_owned()),
|
],
|
||||||
(LedCode::N2, "regular".to_owned()),
|
),
|
||||||
(LedCode::N3, "regular".to_owned()),
|
KeyRow::new(
|
||||||
(LedCode::N4, "regular".to_owned()),
|
0.1,
|
||||||
(LedCode::N5, "regular".to_owned()),
|
0.1,
|
||||||
(LedCode::N6, "regular".to_owned()),
|
vec![
|
||||||
(LedCode::N7, "regular".to_owned()),
|
(LedCode::Tilde, "regular".to_owned()),
|
||||||
(LedCode::N8, "regular".to_owned()),
|
(LedCode::N1, "regular".to_owned()),
|
||||||
(LedCode::N9, "regular".to_owned()),
|
(LedCode::N2, "regular".to_owned()),
|
||||||
(LedCode::N0, "regular".to_owned()),
|
(LedCode::N3, "regular".to_owned()),
|
||||||
(LedCode::Hyphen, "regular".to_owned()),
|
(LedCode::N4, "regular".to_owned()),
|
||||||
(LedCode::Equals, "regular".to_owned()),
|
(LedCode::N5, "regular".to_owned()),
|
||||||
(LedCode::Backspace, "regular".to_owned()),
|
(LedCode::N6, "regular".to_owned()),
|
||||||
]),
|
(LedCode::N7, "regular".to_owned()),
|
||||||
KeyRow::new(0.1, 0.1, vec![
|
(LedCode::N8, "regular".to_owned()),
|
||||||
(LedCode::Tab, "regular".to_owned()),
|
(LedCode::N9, "regular".to_owned()),
|
||||||
(LedCode::Q, "regular".to_owned()),
|
(LedCode::N0, "regular".to_owned()),
|
||||||
(LedCode::W, "regular".to_owned()),
|
(LedCode::Hyphen, "regular".to_owned()),
|
||||||
(LedCode::E, "regular".to_owned()),
|
(LedCode::Equals, "regular".to_owned()),
|
||||||
(LedCode::R, "regular".to_owned()),
|
(LedCode::Backspace, "regular".to_owned()),
|
||||||
(LedCode::T, "regular".to_owned()),
|
],
|
||||||
(LedCode::Y, "regular".to_owned()),
|
),
|
||||||
(LedCode::U, "regular".to_owned()),
|
KeyRow::new(
|
||||||
(LedCode::I, "regular".to_owned()),
|
0.1,
|
||||||
(LedCode::O, "regular".to_owned()),
|
0.1,
|
||||||
(LedCode::P, "regular".to_owned()),
|
vec![
|
||||||
(LedCode::LBracket, "regular".to_owned()),
|
(LedCode::Tab, "regular".to_owned()),
|
||||||
(LedCode::RBracket, "regular".to_owned()),
|
(LedCode::Q, "regular".to_owned()),
|
||||||
(LedCode::BackSlash, "regular".to_owned()),
|
(LedCode::W, "regular".to_owned()),
|
||||||
]),
|
(LedCode::E, "regular".to_owned()),
|
||||||
KeyRow::new(0.1, 0.1, vec![
|
(LedCode::R, "regular".to_owned()),
|
||||||
(LedCode::Caps, "regular".to_owned()),
|
(LedCode::T, "regular".to_owned()),
|
||||||
(LedCode::A, "regular".to_owned()),
|
(LedCode::Y, "regular".to_owned()),
|
||||||
(LedCode::S, "regular".to_owned()),
|
(LedCode::U, "regular".to_owned()),
|
||||||
(LedCode::D, "regular".to_owned()),
|
(LedCode::I, "regular".to_owned()),
|
||||||
(LedCode::F, "regular".to_owned()),
|
(LedCode::O, "regular".to_owned()),
|
||||||
(LedCode::G, "regular".to_owned()),
|
(LedCode::P, "regular".to_owned()),
|
||||||
(LedCode::H, "regular".to_owned()),
|
(LedCode::LBracket, "regular".to_owned()),
|
||||||
(LedCode::J, "regular".to_owned()),
|
(LedCode::RBracket, "regular".to_owned()),
|
||||||
(LedCode::K, "regular".to_owned()),
|
(LedCode::BackSlash, "regular".to_owned()),
|
||||||
(LedCode::L, "regular".to_owned()),
|
],
|
||||||
(LedCode::SemiColon, "regular".to_owned()),
|
),
|
||||||
(LedCode::Quote, "regular".to_owned()),
|
KeyRow::new(
|
||||||
(LedCode::Return, "regular".to_owned()),
|
0.1,
|
||||||
]),
|
0.1,
|
||||||
KeyRow::new(0.1, 0.1, vec![
|
vec![
|
||||||
(LedCode::LShift, "regular".to_owned()),
|
(LedCode::Caps, "regular".to_owned()),
|
||||||
(LedCode::Z, "regular".to_owned()),
|
(LedCode::A, "regular".to_owned()),
|
||||||
(LedCode::X, "regular".to_owned()),
|
(LedCode::S, "regular".to_owned()),
|
||||||
(LedCode::C, "regular".to_owned()),
|
(LedCode::D, "regular".to_owned()),
|
||||||
(LedCode::V, "regular".to_owned()),
|
(LedCode::F, "regular".to_owned()),
|
||||||
(LedCode::B, "regular".to_owned()),
|
(LedCode::G, "regular".to_owned()),
|
||||||
(LedCode::N, "regular".to_owned()),
|
(LedCode::H, "regular".to_owned()),
|
||||||
(LedCode::M, "regular".to_owned()),
|
(LedCode::J, "regular".to_owned()),
|
||||||
(LedCode::Comma, "regular".to_owned()),
|
(LedCode::K, "regular".to_owned()),
|
||||||
(LedCode::Period, "regular".to_owned()),
|
(LedCode::L, "regular".to_owned()),
|
||||||
(LedCode::FwdSlash, "regular".to_owned()),
|
(LedCode::SemiColon, "regular".to_owned()),
|
||||||
(LedCode::Rshift, "regular".to_owned()),
|
(LedCode::Quote, "regular".to_owned()),
|
||||||
]),
|
(LedCode::Return, "regular".to_owned()),
|
||||||
KeyRow::new(0.1, 0.1, vec![
|
],
|
||||||
(LedCode::LCtrl, "regular".to_owned()),
|
),
|
||||||
(LedCode::LFn, "regular".to_owned()),
|
KeyRow::new(
|
||||||
(LedCode::Meta, "regular".to_owned()),
|
0.1,
|
||||||
(LedCode::LAlt, "regular".to_owned()),
|
0.1,
|
||||||
(LedCode::Spacebar, "regular".to_owned()),
|
vec![
|
||||||
(LedCode::RAlt, "regular".to_owned()),
|
(LedCode::LShift, "regular".to_owned()),
|
||||||
(LedCode::PrtSc, "regular".to_owned()),
|
(LedCode::Z, "regular".to_owned()),
|
||||||
(LedCode::RCtrl, "regular".to_owned()),
|
(LedCode::X, "regular".to_owned()),
|
||||||
]),
|
(LedCode::C, "regular".to_owned()),
|
||||||
|
(LedCode::V, "regular".to_owned()),
|
||||||
|
(LedCode::B, "regular".to_owned()),
|
||||||
|
(LedCode::N, "regular".to_owned()),
|
||||||
|
(LedCode::M, "regular".to_owned()),
|
||||||
|
(LedCode::Comma, "regular".to_owned()),
|
||||||
|
(LedCode::Period, "regular".to_owned()),
|
||||||
|
(LedCode::FwdSlash, "regular".to_owned()),
|
||||||
|
(LedCode::Rshift, "regular".to_owned()),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
KeyRow::new(
|
||||||
|
0.1,
|
||||||
|
0.1,
|
||||||
|
vec![
|
||||||
|
(LedCode::LCtrl, "regular".to_owned()),
|
||||||
|
(LedCode::LFn, "regular".to_owned()),
|
||||||
|
(LedCode::Meta, "regular".to_owned()),
|
||||||
|
(LedCode::LAlt, "regular".to_owned()),
|
||||||
|
(LedCode::Spacebar, "regular".to_owned()),
|
||||||
|
(LedCode::RAlt, "regular".to_owned()),
|
||||||
|
(LedCode::PrtSc, "regular".to_owned()),
|
||||||
|
(LedCode::RCtrl, "regular".to_owned()),
|
||||||
|
],
|
||||||
|
),
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -267,18 +267,24 @@ mod tests {
|
|||||||
fn check_cpu() {
|
fn check_cpu() {
|
||||||
let cpu = CPUControl::new().unwrap();
|
let cpu = CPUControl::new().unwrap();
|
||||||
assert_eq!(cpu.get_governor().unwrap(), CPUGovernor::Powersave);
|
assert_eq!(cpu.get_governor().unwrap(), CPUGovernor::Powersave);
|
||||||
assert_eq!(cpu.get_available_governors().unwrap(), vec![
|
assert_eq!(
|
||||||
CPUGovernor::Performance,
|
cpu.get_available_governors().unwrap(),
|
||||||
CPUGovernor::Powersave
|
vec![
|
||||||
]);
|
CPUGovernor::Performance,
|
||||||
|
CPUGovernor::Powersave
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(cpu.get_epp().unwrap(), CPUEPP::BalancePower);
|
assert_eq!(cpu.get_epp().unwrap(), CPUEPP::BalancePower);
|
||||||
assert_eq!(cpu.get_available_epp().unwrap(), vec![
|
assert_eq!(
|
||||||
CPUEPP::Default,
|
cpu.get_available_epp().unwrap(),
|
||||||
CPUEPP::Performance,
|
vec![
|
||||||
CPUEPP::BalancePerformance,
|
CPUEPP::Default,
|
||||||
CPUEPP::BalancePower,
|
CPUEPP::Performance,
|
||||||
CPUEPP::Power,
|
CPUEPP::BalancePerformance,
|
||||||
]);
|
CPUEPP::BalancePower,
|
||||||
|
CPUEPP::Power,
|
||||||
|
]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user