Skip to content

Commit

Permalink
19 display icon next to vault entry (#21)
Browse files Browse the repository at this point in the history
The icon defaults to "obsidian" but can be configured either through a
flag or in the config file, the former taking precedence.

Closes #19
  • Loading branch information
nydragon authored May 30, 2024
2 parents 0e9c509 + 000fd9d commit 2cf82cc
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cliff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ body = """
{% else %}\
## [unreleased]
{% endif %}\
{% for group, commits in commits | group_by(attribute="group") %}
{% for group, commits in commits | filter(attribute="merge_commit", value=false) | group_by(attribute="group") %}
### {{ group | striptags | trim | upper_first }}
{% for commit in commits %}
- {% if commit.scope %}*({{ commit.scope }})* {% endif %}\
Expand Down
2 changes: 2 additions & 0 deletions src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,6 @@ pub struct Args {
pub selection: Option<String>,
#[clap(short, long, help = "The style of the vault name")]
pub name: Option<DisplayName>,
#[clap(short, long, help = "The icon to display for each entry")]
pub icon: Option<String>,
}
6 changes: 6 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ pub enum DisplayName {
pub struct Config {
pub display_name: DisplayName,
pub source: Source,
#[serde(default = "default_icon")]
pub icon: String,
}

#[derive(Serialize, Deserialize, Debug)]
Expand Down Expand Up @@ -50,6 +52,10 @@ impl Config {
}
}

fn default_icon() -> String {
"obsidian".to_string()
}

impl Default for Source {
fn default() -> Self {
Self {
Expand Down
3 changes: 2 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ fn get_known_vaults(conf: &Config) -> Vec<String> {
fn rofi_main(state: u8, conf: Config, args: Args) -> Result<()> {
let rofi_info: String = env::var("ROFI_INFO").unwrap_or_default();
let name_style = args.name.unwrap_or(conf.display_name.clone());
let icon = args.icon.unwrap_or(conf.icon.clone());

match state {
// Prompting which vault to open
Expand All @@ -107,7 +108,7 @@ fn rofi_main(state: u8, conf: Config, args: Args) -> Result<()> {
DisplayName::Unique => unique_names.get(i).unwrap(),
};

println!("{name}\0info\x1f{vault}");
println!("{name}\0icon\x1f{icon}\x1finfo\x1f{vault}");
});
}
// Opening the selected vault
Expand Down

0 comments on commit 2cf82cc

Please sign in to comment.