clippy fixes

This commit is contained in:
2026-03-30 15:53:03 +02:00
parent 78c004bcb4
commit c1b3d9134e
2 changed files with 6 additions and 10 deletions
+6 -9
View File
@@ -26,8 +26,8 @@ impl WaybarModule for BtModule {
}); });
} }
if let Ok(stdout) = run_command("bluetoothctl", &["show"]) { if let Ok(stdout) = run_command("bluetoothctl", &["show"])
if stdout.contains("Powered: no") { && stdout.contains("Powered: no") {
return Ok(WaybarOutput { return Ok(WaybarOutput {
text: config.bt.format_disabled.clone(), text: config.bt.format_disabled.clone(),
tooltip: Some("Bluetooth Disabled".to_string()), tooltip: Some("Bluetooth Disabled".to_string()),
@@ -35,7 +35,6 @@ impl WaybarModule for BtModule {
percentage: None, percentage: None,
}); });
} }
}
if let Some(mac) = find_audio_device() { if let Some(mac) = find_audio_device() {
let info = run_command("bluetoothctl", &["info", &mac])?; let info = run_command("bluetoothctl", &["info", &mac])?;
@@ -90,14 +89,13 @@ impl WaybarModule for BtModule {
} }
fn find_audio_device() -> Option<String> { fn find_audio_device() -> Option<String> {
if let Ok(sink) = run_command("pactl", &["get-default-sink"]) { if let Ok(sink) = run_command("pactl", &["get-default-sink"])
if sink.starts_with("bluez_output.") { && sink.starts_with("bluez_output.") {
let parts: Vec<&str> = sink.split('.').collect(); let parts: Vec<&str> = sink.split('.').collect();
if parts.len() >= 2 { if parts.len() >= 2 {
return Some(parts[1].replace('_', ":")); return Some(parts[1].replace('_', ":"));
} }
} }
}
if let Ok(stdout) = run_command("bluetoothctl", &["devices", "Connected"]) { if let Ok(stdout) = run_command("bluetoothctl", &["devices", "Connected"]) {
for line in stdout.lines() { for line in stdout.lines() {
@@ -105,11 +103,10 @@ fn find_audio_device() -> Option<String> {
let parts: Vec<&str> = line.split_whitespace().collect(); let parts: Vec<&str> = line.split_whitespace().collect();
if parts.len() >= 2 { if parts.len() >= 2 {
let mac = parts[1]; let mac = parts[1];
if let Ok(info_str) = run_command("bluetoothctl", &["info", mac]) { if let Ok(info_str) = run_command("bluetoothctl", &["info", mac])
if info_str.contains("0000110b-0000-1000-8000-00805f9b34fb") { && info_str.contains("0000110b-0000-1000-8000-00805f9b34fb") {
return Some(mac.to_string()); return Some(mac.to_string());
} }
}
} }
} }
} }
-1
View File
@@ -1,7 +1,6 @@
use anyhow::{Context, Result}; use anyhow::{Context, Result};
use std::io::Write; use std::io::Write;
use std::process::{Command, Stdio}; use std::process::{Command, Stdio};
use tracing::warn;
/// Run an external command and return its stdout as a trimmed String. /// Run an external command and return its stdout as a trimmed String.
/// Provides clear error messages when the command is not found or fails. /// Provides clear error messages when the command is not found or fails.