From 7a8f70938eedbe86dca4198a8debe1848a1eb325 Mon Sep 17 00:00:00 2001 From: Nils Pukropp Date: Wed, 1 Apr 2026 14:01:16 +0200 Subject: [PATCH] removed legacy code and clippy fixes + fixed ci --- .gitea/workflows/release.yml | 2 +- Cargo.lock | 2 +- src/config.rs | 18 ------------------ src/main.rs | 19 ++++++++----------- src/modules/audio.rs | 4 ++-- src/modules/bt.rs | 9 ++++----- src/modules/network.rs | 11 +++++------ src/output.rs | 13 +------------ src/test_pbpctrl.rs | 5 ----- 9 files changed, 22 insertions(+), 61 deletions(-) delete mode 100644 src/test_pbpctrl.rs diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index bacc583..036b071 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -22,7 +22,7 @@ jobs: cache: false - name: Install packaging tools - run: apt-get update && apt-get install -y dpkg-dev + run: apt-get update && apt-get install -y dpkg-dev pkg-config - name: Get Version id: get_version diff --git a/Cargo.lock b/Cargo.lock index b63ee56..7bc0971 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -353,7 +353,7 @@ checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99" [[package]] name = "fluxo-rs" -version = "0.2.0" +version = "0.3.0" dependencies = [ "anyhow", "bluer", diff --git a/src/config.rs b/src/config.rs index c1675d9..ca82b67 100644 --- a/src/config.rs +++ b/src/config.rs @@ -26,8 +26,6 @@ pub struct Config { #[serde(default)] pub power: PowerConfig, #[serde(default)] - pub buds: BudsConfig, - #[serde(default)] pub audio: AudioConfig, #[serde(default)] pub bt: BtConfig, @@ -158,21 +156,6 @@ impl Default for PowerConfig { } } -#[derive(Deserialize)] -pub struct BudsConfig { - pub format: String, - pub format_disconnected: String, -} - -impl Default for BudsConfig { - fn default() -> Self { - Self { - format: "{left} | {right} | {anc}".to_string(), - format_disconnected: "".to_string(), - } - } -} - #[derive(Deserialize)] pub struct AudioConfig { pub format_sink_unmuted: String, @@ -275,7 +258,6 @@ impl Config { validate_format("disk", &self.disk.format, &["mount", "used", "total"]); validate_format("pool", &self.pool.format, &["used", "total"]); validate_format("power", &self.power.format, &["percentage", "icon"]); - validate_format("buds", &self.buds.format, &["left", "right", "anc"]); validate_format( "audio.sink_unmuted", &self.audio.format_sink_unmuted, diff --git a/src/main.rs b/src/main.rs index 8ffc44c..24bd5d4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -123,15 +123,13 @@ fn main() { let mut items = Vec::new(); // If connected, show plugin modes and disconnect - if let Ok(json_str) = ipc::request_data("bt", &["get_modes"]) { - if let Ok(val) = serde_json::from_str::(&json_str) { - if let Some(modes_str) = val.get("text").and_then(|t| t.as_str()) { - if !modes_str.is_empty() { - for mode in modes_str.lines() { - items.push(format!("Mode: {}", mode)); - } - } - } + if let Ok(json_str) = ipc::request_data("bt", &["get_modes"]) + && let Ok(val) = serde_json::from_str::(&json_str) + && let Some(modes_str) = val.get("text").and_then(|t| t.as_str()) + && !modes_str.is_empty() + { + for mode in modes_str.lines() { + items.push(format!("Mode: {}", mode)); } } @@ -166,8 +164,7 @@ fn main() { if let Ok(selected) = utils::show_menu("BT Menu: ", &items, &config.general.menu_command) { - if selected.starts_with("Mode: ") { - let mode = &selected[6..]; + if let Some(mode) = selected.strip_prefix("Mode: ") { handle_ipc_response(ipc::request_data("bt", &["set_mode", mode])); } else if selected == "Disconnect" { handle_ipc_response(ipc::request_data("bt", &["disconnect"])); diff --git a/src/modules/audio.rs b/src/modules/audio.rs index dae42c6..795525d 100644 --- a/src/modules/audio.rs +++ b/src/modules/audio.rs @@ -121,7 +121,7 @@ fn fetch_audio_data_sync(context: &mut Context, state: &SharedState) -> Result<( let is_default = item .name .as_ref() - .map(|s| s.to_string() == lock.audio.sink.name) + .map(|s| s.as_ref() == lock.audio.sink.name) .unwrap_or(false); if is_default { lock.audio.sink.description = item @@ -143,7 +143,7 @@ fn fetch_audio_data_sync(context: &mut Context, state: &SharedState) -> Result<( let is_default = item .name .as_ref() - .map(|s| s.to_string() == lock.audio.source.name) + .map(|s| s.as_ref() == lock.audio.source.name) .unwrap_or(false); if is_default { lock.audio.source.description = item diff --git a/src/modules/bt.rs b/src/modules/bt.rs index a32d359..63f9a40 100644 --- a/src/modules/bt.rs +++ b/src/modules/bt.rs @@ -226,12 +226,11 @@ async fn buds_task( if let Ok(val) = service .read_setting_var(settings::SettingId::CurrentAncrState) .await + && let SettingValue::CurrentAncrState(anc_state) = val { - if let SettingValue::CurrentAncrState(anc_state) = val { - let mut status = MAESTRO.get_status(mac); - status.anc_state = anc_state_to_string(&anc_state); - statuses.lock().unwrap().insert(mac.to_string(), status); - } + let mut status = MAESTRO.get_status(mac); + status.anc_state = anc_state_to_string(&anc_state); + statuses.lock().unwrap().insert(mac.to_string(), status); } // Subscribe to real-time status updates (battery, ANC, wear) diff --git a/src/modules/network.rs b/src/modules/network.rs index 9fa1355..876e628 100644 --- a/src/modules/network.rs +++ b/src/modules/network.rs @@ -175,12 +175,11 @@ fn get_primary_interface() -> Result { fn get_ip_address(interface: &str) -> Option { let addrs = getifaddrs().ok()?; for ifaddr in addrs { - if ifaddr.interface_name == interface { - if let Some(address) = ifaddr.address { - if let Some(sockaddr) = address.as_sockaddr_in() { - return Some(sockaddr.ip().to_string()); - } - } + if ifaddr.interface_name == interface + && let Some(address) = ifaddr.address + && let Some(sockaddr) = address.as_sockaddr_in() + { + return Some(sockaddr.ip().to_string()); } } None diff --git a/src/output.rs b/src/output.rs index b35658a..76cfeea 100644 --- a/src/output.rs +++ b/src/output.rs @@ -1,6 +1,6 @@ use serde::Serialize; -#[derive(Serialize)] +#[derive(Serialize, Default)] pub struct WaybarOutput { pub text: String, #[serde(skip_serializing_if = "Option::is_none")] @@ -11,17 +11,6 @@ pub struct WaybarOutput { pub percentage: Option, } -impl Default for WaybarOutput { - fn default() -> Self { - Self { - text: String::new(), - tooltip: None, - class: None, - percentage: None, - } - } -} - #[cfg(test)] mod tests { use super::*; diff --git a/src/test_pbpctrl.rs b/src/test_pbpctrl.rs deleted file mode 100644 index 2dd09fe..0000000 --- a/src/test_pbpctrl.rs +++ /dev/null @@ -1,5 +0,0 @@ -use pbpctrl::Controller; - -fn main() { - let _ = Controller::connect("AA:BB:CC:DD:EE:FF"); -}