Skip to content

Commit

Permalink
fix: change icons to string, move default back
Browse files Browse the repository at this point in the history
Unbreaking previous commit
  • Loading branch information
roosta committed Dec 23, 2024
1 parent 9b8d18a commit 155e278
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion assets/example_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ Gpick = ""
Nautilus = "📘"
# smile emoji
MyNiceProgram = "😛"
default_icon = ""

[aliases.class]
TelegramDesktop = "Telegram"
Expand All @@ -25,6 +24,7 @@ separator = "  "
split_at = ":"
empty_label = "🌕"
display_property = "instance" # class, instance, name
default_icon = ""

[options]
remove_duplicates = false
Expand Down
6 changes: 3 additions & 3 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::path::Path;
use thiserror::Error;

type StringMap = HashMap<String, String>;
type IconMap = HashMap<String, char>;
type IconMap = HashMap<String, String>;
type OptionMap = HashMap<String, bool>;

#[derive(Error, Debug)]
Expand Down Expand Up @@ -90,8 +90,8 @@ impl Config {
}

/// Gets an icon by key
pub fn get_icon(&self, key: &str) -> Option<char> {
self.icons.get(key).copied()
pub fn get_icon(&self, key: &str) -> Option<String> {
self.icons.get(key).map(|s| s.to_string())
}

/// Sets a general configuration value
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ fn find_alias(
value.and_then(|val| patterns.iter().find(|(re, _)| re.is_match(val)).map(|(_, alias)| alias.clone()))
}

fn format_with_icon(icon: &char, title: &str, no_names: bool, no_icon_names: bool) -> String {
fn format_with_icon(icon: &str, title: &str, no_names: bool, no_icon_names: bool) -> String {
if no_icon_names || no_names {
icon.to_string()
} else {
Expand Down Expand Up @@ -147,7 +147,7 @@ pub fn get_title(

Ok(if let Some(icon) = config.get_icon(&title) {
format_with_icon(&icon, &title, no_names, no_icon_names)
} else if let Some(default_icon) = config.get_icon("default_icon") {
} else if let Some(default_icon) = config.get_general("default_icon") {
format_with_icon(&default_icon, &title, no_names, no_icon_names)
} else if no_names {
String::new()
Expand Down

0 comments on commit 155e278

Please sign in to comment.