Skip to content

Commit 6fea8dc

Browse files
abachmannmmstick
authored andcommitted
improve(bluetooth): ignore devices with unknown type and without alias
1 parent 91dadae commit 6fea8dc

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

cosmic-settings/src/pages/bluetooth/backend.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ impl PartialEq for Adapter {
158158

159159
impl Eq for Adapter {}
160160

161+
const default_device_icon: &str = "bluetooth-symbolic";
162+
161163
fn device_type_to_icon(device_type: &str) -> &'static str {
162164
match device_type {
163165
"computer" => "laptop-symbolic",
@@ -173,7 +175,7 @@ fn device_type_to_icon(device_type: &str) -> &'static str {
173175
"input-mouse" => "input-mouse-symbolic",
174176
"printer" => "printer-network-symbolic",
175177
"camera-photo" => "camera-photo-symbolic",
176-
_ => "bluetooth-symbolic",
178+
_ => default_device_icon,
177179
}
178180
}
179181

@@ -266,6 +268,10 @@ impl Device {
266268
self.alias.is_some()
267269
}
268270
#[must_use]
271+
pub fn is_known_device_type(&self) -> bool {
272+
self.icon != default_device_icon
273+
}
274+
#[must_use]
269275
pub fn alias_or_addr(&self) -> &str {
270276
self.alias.as_ref().unwrap_or(&self.address)
271277
}

cosmic-settings/src/pages/bluetooth/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,10 @@ fn available_devices() -> Section<crate::pages::Message> {
746746
return None::<Element<'_, Message>>;
747747
}
748748

749+
if !device.is_known_device_type() && !device.has_alias() {
750+
return None::<Element<'_, Message>>;
751+
}
752+
749753
let mut items = vec![
750754
widget::icon::from_name(device.icon).size(16).into(),
751755
text(device.alias_or_addr()).wrapping(Wrapping::Word).into(),

0 commit comments

Comments
 (0)