From b4614b0f266624f5cf4ec4fadcefd1d1f04d9756 Mon Sep 17 00:00:00 2001 From: Maxime Tricoire Date: Sun, 14 Apr 2024 18:45:39 +0200 Subject: [PATCH] also clean bin(s) --- bin/acpi.rs | 2 +- bin/ipc.rs | 30 ++++++++++++++++-------------- bin/sensors.rs | 2 +- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/bin/acpi.rs b/bin/acpi.rs index 5dac9e7..9e77464 100644 --- a/bin/acpi.rs +++ b/bin/acpi.rs @@ -17,7 +17,7 @@ fn main() -> Result<()> { let (output, _) = local_block_on(async { let mut acpi = netlink_acpi_listen().await?; while let Some(event) = acpi.recv().await { - let line = format!("{}", serde_json::to_string(&event)?); + let line = serde_json::to_string(&event)?; // flush output each time to facilitate common usage patterns, such as // `i3stat-acpi | while read x; do ... done`, etc. diff --git a/bin/ipc.rs b/bin/ipc.rs index 35a476a..9076449 100644 --- a/bin/ipc.rs +++ b/bin/ipc.rs @@ -239,11 +239,11 @@ fn main() -> Result<()> { match theme.pointer_mut(&pointer) { Some(value) => { let trimmed = json_value.trim(); - let new_value = match serde_json::from_str::(&trimmed) { + let new_value = match serde_json::from_str::(trimmed) { // passed a direct JSON value Ok(value) => Ok(value), // assume string if it doesn't definitely look like some JSON value - Err(_) if !trimmed.starts_with(&['[', '{', '\'', '"']) => { + Err(_) if !trimmed.starts_with(['[', '{', '\'', '"']) => { Ok(Value::String(trimmed.into())) } // pass through any other error @@ -273,18 +273,20 @@ fn main() -> Result<()> { width, height, } => { - let mut click = I3ClickEvent::default(); - click.button = button.0; - click.instance = Some(target.clone()); - click.modifiers = modifiers.into_iter().map(|m| m.0).collect(); - x.map(|x| click.x = x); - y.map(|y| click.y = y); - relative_x.map(|relative_x| click.relative_x = relative_x); - relative_y.map(|relative_y| click.relative_y = relative_y); - output_x.map(|output_x| click.output_x = output_x); - output_y.map(|output_y| click.output_y = output_y); - width.map(|width| click.width = width); - height.map(|height| click.height = height); + let click = I3ClickEvent { + name: None, + button: button.0, + instance: Some(target.clone()), + modifiers: modifiers.into_iter().map(|m| m.0).collect(), + x: x.unwrap_or_default(), + y: y.unwrap_or_default(), + relative_x: relative_x.unwrap_or_default(), + relative_y: relative_y.unwrap_or_default(), + output_x: output_x.unwrap_or_default(), + output_y: output_y.unwrap_or_default(), + width: width.unwrap_or_default(), + height: height.unwrap_or_default(), + }; let event = IpcBarEvent::Click(click); send_and_print_response( diff --git a/bin/sensors.rs b/bin/sensors.rs index 64537ee..c81dfd5 100644 --- a/bin/sensors.rs +++ b/bin/sensors.rs @@ -18,7 +18,7 @@ fn main() { let sys = System::new_with_specifics(RefreshKind::new().with_components_list()); sys.components() - .into_iter() + .iter() .for_each(|c| println!("{:>width$.2}°C:{}", c.temperature(), c.label(), width = 6)); }