Skip to content

Commit

Permalink
refactor: align name display when icon is not present
Browse files Browse the repository at this point in the history
  • Loading branch information
pythops committed May 9, 2024
1 parent 12c2336 commit 45f00f8
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions src/bluetooth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,18 @@ pub struct Device {

// https://specifications.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html
impl Device {
pub fn get_icon(name: &str) -> String {
pub fn get_icon(name: &str) -> Option<String> {
match name {
"audio-card" => String::from("󰓃"),
"audio-input-microphone" => String::from("ο„°"),
"audio-headphones" => String::from("σ°‹‹"),
"battery" => String::from("σ°‚€"),
"camera-photo" => String::from("σ°»›"),
"computer" => String::from(""),
"input-keyboard" => String::from("󰌌"),
"input-mouse" => String::from("󰍽"),
"phone" => String::from("󰏲"),
_ => String::from(" "),
"audio-card" => Some(String::from("󰓃")),
"audio-input-microphone" => Some(String::from("ο„°")),
"audio-headphones" => Some(String::from("σ°‹‹")),
"battery" => Some(String::from("σ°‚€")),
"camera-photo" => Some(String::from("σ°»›")),
"computer" => Some(String::from("")),
"input-keyboard" => Some(String::from("󰌌")),
"input-mouse" => Some(String::from("󰍽")),
"phone" => Some(String::from("󰏲")),
_ => None,
}
}
}
Expand Down Expand Up @@ -103,7 +103,13 @@ impl Controller {

let device = Device {
addr,
alias: format!("{} {}", icon, alias),
alias: {
if let Some(icon) = icon {
format!("{} {}", icon, alias)
} else {
alias
}
},
is_paired,
is_trusted,
is_connected,
Expand Down

0 comments on commit 45f00f8

Please sign in to comment.