chore: cargo fmt

This commit is contained in:
Denis Benato
2025-10-08 01:01:43 +02:00
parent 1ab1adf937
commit b2e7211bbe
6 changed files with 158 additions and 216 deletions

View File

@@ -21,14 +21,11 @@ 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( seq.insert(0, &ActionLoader::AsusAnimation {
0, file: path.into(),
&ActionLoader::AsusAnimation { time: rog_anime::AnimTime::Infinite,
file: path.into(), brightness,
time: rog_anime::AnimTime::Infinite, })
brightness,
},
)
.unwrap(); .unwrap();
loop { loop {

View File

@@ -91,7 +91,8 @@ impl AsusArmouryAttribute {
.await; .await;
} else { } else {
info!( info!(
"inotify event stream failed for {} ({}). You can ignore this if unsupported", "inotify event stream failed for {} ({}). You can ignore this \
if unsupported",
name, $attr_str name, $attr_str
); );
} }

View File

@@ -295,38 +295,26 @@ 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!( assert_eq!(sta[0].colour1, Colour {
sta[0].colour1, r: 0xff,
Colour { g: 0x00,
r: 0xff, b: 0xff
g: 0x00, });
b: 0xff assert_eq!(sta[1].colour1, Colour {
} r: 0x00,
); g: 0xff,
assert_eq!( b: 0xff
sta[1].colour1, });
Colour { assert_eq!(sta[2].colour1, Colour {
r: 0x00, r: 0xff,
g: 0xff, g: 0xff,
b: 0xff b: 0x00
} });
); assert_eq!(sta[3].colour1, Colour {
assert_eq!( r: 0x00,
sta[2].colour1, g: 0xff,
Colour { b: 0x00
r: 0xff, });
g: 0xff,
b: 0x00
}
);
assert_eq!(
sta[3].colour1,
Colour {
r: 0x00,
g: 0xff,
b: 0x00
}
);
} }
#[test] #[test]
@@ -384,28 +372,22 @@ 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!( assert_eq!(config.builtins.first_entry().unwrap().get(), &AuraEffect {
config.builtins.first_entry().unwrap().get(), mode: AuraModeNum::Static,
&AuraEffect { zone: AuraZone::None,
mode: AuraModeNum::Static, colour1: Colour { r: 166, g: 0, b: 0 },
zone: AuraZone::None, colour2: Colour { r: 0, g: 0, b: 0 },
colour1: Colour { r: 166, g: 0, b: 0 }, speed: Speed::Med,
colour2: Colour { r: 0, g: 0, b: 0 }, direction: Direction::Right
speed: Speed::Med, });
direction: Direction::Right
}
);
assert_eq!(config.enabled.states.len(), 1); assert_eq!(config.enabled.states.len(), 1);
assert_eq!( assert_eq!(config.enabled.states[0], AuraPowerState {
config.enabled.states[0], zone: PowerZones::KeyboardAndLightbar,
AuraPowerState { boot: true,
zone: PowerZones::KeyboardAndLightbar, awake: true,
boot: true, sleep: true,
awake: true, shutdown: true
sleep: true, });
shutdown: true
}
);
} }
#[test] #[test]
@@ -415,27 +397,21 @@ 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!( assert_eq!(config.builtins.first_entry().unwrap().get(), &AuraEffect {
config.builtins.first_entry().unwrap().get(), mode: AuraModeNum::Static,
&AuraEffect { zone: AuraZone::None,
mode: AuraModeNum::Static, colour1: Colour { r: 166, g: 0, b: 0 },
zone: AuraZone::None, colour2: Colour { r: 0, g: 0, b: 0 },
colour1: Colour { r: 166, g: 0, b: 0 }, speed: Speed::Med,
colour2: Colour { r: 0, g: 0, b: 0 }, direction: Direction::Right
speed: Speed::Med, });
direction: Direction::Right
}
);
assert_eq!(config.enabled.states.len(), 4); assert_eq!(config.enabled.states.len(), 4);
assert_eq!( assert_eq!(config.enabled.states[0], AuraPowerState {
config.enabled.states[0], zone: PowerZones::Keyboard,
AuraPowerState { boot: true,
zone: PowerZones::Keyboard, awake: true,
boot: true, sleep: true,
awake: true, shutdown: true
sleep: true, });
shutdown: true
}
);
} }
} }

View File

@@ -207,14 +207,12 @@ 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.push(Effect::Static(Static::new( seq.effects
LedCode::F, .push(Effect::Static(Static::new(LedCode::F, Colour {
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();

View File

@@ -335,117 +335,93 @@ 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( KeyRow::new(0.1, 0.1, vec![
0.1, (LedCode::Esc, "regular".to_owned()),
0.1, (LedCode::F1, "regular".to_owned()),
vec![ (LedCode::F2, "regular".to_owned()),
(LedCode::Esc, "regular".to_owned()), (LedCode::F3, "regular".to_owned()),
(LedCode::F1, "regular".to_owned()), (LedCode::F4, "regular".to_owned()),
(LedCode::F2, "regular".to_owned()), // not sure which key to put here
(LedCode::F3, "regular".to_owned()), (LedCode::F5, "regular".to_owned()),
(LedCode::F4, "regular".to_owned()), (LedCode::F6, "regular".to_owned()),
// not sure which key to put here (LedCode::F7, "regular".to_owned()),
(LedCode::F5, "regular".to_owned()), (LedCode::F8, "regular".to_owned()),
(LedCode::F6, "regular".to_owned()), (LedCode::F9, "regular".to_owned()),
(LedCode::F7, "regular".to_owned()), (LedCode::F10, "regular".to_owned()),
(LedCode::F8, "regular".to_owned()), (LedCode::F11, "regular".to_owned()),
(LedCode::F9, "regular".to_owned()), (LedCode::F12, "regular".to_owned()),
(LedCode::F10, "regular".to_owned()), ]),
(LedCode::F11, "regular".to_owned()), KeyRow::new(0.1, 0.1, vec![
(LedCode::F12, "regular".to_owned()), (LedCode::Tilde, "regular".to_owned()),
], (LedCode::N1, "regular".to_owned()),
), (LedCode::N2, "regular".to_owned()),
KeyRow::new( (LedCode::N3, "regular".to_owned()),
0.1, (LedCode::N4, "regular".to_owned()),
0.1, (LedCode::N5, "regular".to_owned()),
vec![ (LedCode::N6, "regular".to_owned()),
(LedCode::Tilde, "regular".to_owned()), (LedCode::N7, "regular".to_owned()),
(LedCode::N1, "regular".to_owned()), (LedCode::N8, "regular".to_owned()),
(LedCode::N2, "regular".to_owned()), (LedCode::N9, "regular".to_owned()),
(LedCode::N3, "regular".to_owned()), (LedCode::N0, "regular".to_owned()),
(LedCode::N4, "regular".to_owned()), (LedCode::Hyphen, "regular".to_owned()),
(LedCode::N5, "regular".to_owned()), (LedCode::Equals, "regular".to_owned()),
(LedCode::N6, "regular".to_owned()), (LedCode::Backspace, "regular".to_owned()),
(LedCode::N7, "regular".to_owned()), ]),
(LedCode::N8, "regular".to_owned()), KeyRow::new(0.1, 0.1, vec![
(LedCode::N9, "regular".to_owned()), (LedCode::Tab, "regular".to_owned()),
(LedCode::N0, "regular".to_owned()), (LedCode::Q, "regular".to_owned()),
(LedCode::Hyphen, "regular".to_owned()), (LedCode::W, "regular".to_owned()),
(LedCode::Equals, "regular".to_owned()), (LedCode::E, "regular".to_owned()),
(LedCode::Backspace, "regular".to_owned()), (LedCode::R, "regular".to_owned()),
], (LedCode::T, "regular".to_owned()),
), (LedCode::Y, "regular".to_owned()),
KeyRow::new( (LedCode::U, "regular".to_owned()),
0.1, (LedCode::I, "regular".to_owned()),
0.1, (LedCode::O, "regular".to_owned()),
vec![ (LedCode::P, "regular".to_owned()),
(LedCode::Tab, "regular".to_owned()), (LedCode::LBracket, "regular".to_owned()),
(LedCode::Q, "regular".to_owned()), (LedCode::RBracket, "regular".to_owned()),
(LedCode::W, "regular".to_owned()), (LedCode::BackSlash, "regular".to_owned()),
(LedCode::E, "regular".to_owned()), ]),
(LedCode::R, "regular".to_owned()), KeyRow::new(0.1, 0.1, vec![
(LedCode::T, "regular".to_owned()), (LedCode::Caps, "regular".to_owned()),
(LedCode::Y, "regular".to_owned()), (LedCode::A, "regular".to_owned()),
(LedCode::U, "regular".to_owned()), (LedCode::S, "regular".to_owned()),
(LedCode::I, "regular".to_owned()), (LedCode::D, "regular".to_owned()),
(LedCode::O, "regular".to_owned()), (LedCode::F, "regular".to_owned()),
(LedCode::P, "regular".to_owned()), (LedCode::G, "regular".to_owned()),
(LedCode::LBracket, "regular".to_owned()), (LedCode::H, "regular".to_owned()),
(LedCode::RBracket, "regular".to_owned()), (LedCode::J, "regular".to_owned()),
(LedCode::BackSlash, "regular".to_owned()), (LedCode::K, "regular".to_owned()),
], (LedCode::L, "regular".to_owned()),
), (LedCode::SemiColon, "regular".to_owned()),
KeyRow::new( (LedCode::Quote, "regular".to_owned()),
0.1, (LedCode::Return, "regular".to_owned()),
0.1, ]),
vec![ KeyRow::new(0.1, 0.1, vec![
(LedCode::Caps, "regular".to_owned()), (LedCode::LShift, "regular".to_owned()),
(LedCode::A, "regular".to_owned()), (LedCode::Z, "regular".to_owned()),
(LedCode::S, "regular".to_owned()), (LedCode::X, "regular".to_owned()),
(LedCode::D, "regular".to_owned()), (LedCode::C, "regular".to_owned()),
(LedCode::F, "regular".to_owned()), (LedCode::V, "regular".to_owned()),
(LedCode::G, "regular".to_owned()), (LedCode::B, "regular".to_owned()),
(LedCode::H, "regular".to_owned()), (LedCode::N, "regular".to_owned()),
(LedCode::J, "regular".to_owned()), (LedCode::M, "regular".to_owned()),
(LedCode::K, "regular".to_owned()), (LedCode::Comma, "regular".to_owned()),
(LedCode::L, "regular".to_owned()), (LedCode::Period, "regular".to_owned()),
(LedCode::SemiColon, "regular".to_owned()), (LedCode::FwdSlash, "regular".to_owned()),
(LedCode::Quote, "regular".to_owned()), (LedCode::Rshift, "regular".to_owned()),
(LedCode::Return, "regular".to_owned()), ]),
], KeyRow::new(0.1, 0.1, vec![
), (LedCode::LCtrl, "regular".to_owned()),
KeyRow::new( (LedCode::LFn, "regular".to_owned()),
0.1, (LedCode::Meta, "regular".to_owned()),
0.1, (LedCode::LAlt, "regular".to_owned()),
vec![ (LedCode::Spacebar, "regular".to_owned()),
(LedCode::LShift, "regular".to_owned()), (LedCode::RAlt, "regular".to_owned()),
(LedCode::Z, "regular".to_owned()), (LedCode::PrtSc, "regular".to_owned()),
(LedCode::X, "regular".to_owned()), (LedCode::RCtrl, "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()),
],
),
], ],
} }
} }

View File

@@ -267,24 +267,18 @@ 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!( assert_eq!(cpu.get_available_governors().unwrap(), vec![
cpu.get_available_governors().unwrap(), CPUGovernor::Performance,
vec![ CPUGovernor::Powersave
CPUGovernor::Performance, ]);
CPUGovernor::Powersave
]
);
assert_eq!(cpu.get_epp().unwrap(), CPUEPP::BalancePower); assert_eq!(cpu.get_epp().unwrap(), CPUEPP::BalancePower);
assert_eq!( assert_eq!(cpu.get_available_epp().unwrap(), vec![
cpu.get_available_epp().unwrap(), CPUEPP::Default,
vec![ CPUEPP::Performance,
CPUEPP::Default, CPUEPP::BalancePerformance,
CPUEPP::Performance, CPUEPP::BalancePower,
CPUEPP::BalancePerformance, CPUEPP::Power,
CPUEPP::BalancePower, ]);
CPUEPP::Power,
]
);
} }
} }