Skip to content

Commit

Permalink
improve(bluetooth): ignore devices with unknown type and without alias
Browse files Browse the repository at this point in the history
  • Loading branch information
abachmann committed Feb 8, 2025
1 parent fd15399 commit cda1230
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions cosmic-applet-bluetooth/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,7 @@ impl cosmic::Application for CosmicBluetoothApplet {
.request_confirmation
.as_ref()
.map_or(false, |(dev, _, _)| d.address == dev.address)
&& (d.has_name() || d.is_known_device_type())
}) {
let row = row![
icon::from_name(dev.icon.as_str()).size(16).symbolic(true),
Expand Down
14 changes: 13 additions & 1 deletion cosmic-applet-bluetooth/src/bluetooth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@ impl PartialEq for BluerDevice {
}
}

const default_device_icon: &str = "bluetooth-symbolic";

impl BluerDevice {
pub async fn from_device(device: &bluer::Device) -> Self {
let mut name = device
Expand Down Expand Up @@ -251,7 +253,7 @@ impl BluerDevice {
None
}
})
.unwrap_or_else(|| "bluetooth-symbolic".into());
.unwrap_or_else(|| default_device_icon.into());

Self {
name,
Expand All @@ -274,6 +276,16 @@ impl BluerDevice {
.count()
== 2
}

#[must_use]
pub fn is_known_device_type(&self) -> bool {
self.icon != default_device_icon
}

#[must_use]
pub fn has_name(&self) -> bool {
self.name != self.address.to_string()
}
}

#[derive(Debug, Clone)]
Expand Down

0 comments on commit cda1230

Please sign in to comment.