Skip to content

Commit 346c4fe

Browse files
committed
config: support yofi.toml filename
Allows editors to more easily syntax highlight.
1 parent f773614 commit 346c4fe

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Features
44

5+
- config.toml is now additionally supported.
6+
57
## Changes
68

79
## Fixes

src/config.rs

+17-11
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ use serde::Deserialize;
88
use crate::style::{Margin, Padding, Radius};
99
use crate::Color;
1010

11-
const DEFAULT_CONFIG_NAME: &str = concat!(crate::prog_name!(), ".config");
11+
const DEFAULT_CONFIG_NAMES: [&str; 2] = [
12+
concat!(crate::prog_name!(), ".toml"),
13+
concat!(crate::prog_name!(), ".config"),
14+
];
1215

1316
const DEFAULT_ICON_SIZE: u16 = 16;
1417
const DEFAULT_FONT_SIZE: u16 = 24;
@@ -112,17 +115,20 @@ struct Icon {
112115
}
113116

114117
fn default_config_path() -> Result<Option<PathBuf>> {
115-
let file = xdg::BaseDirectories::with_prefix(crate::prog_name!())
116-
.context("failed to get xdg dirs")?
117-
.get_config_file(DEFAULT_CONFIG_NAME);
118-
if file
119-
.try_exists()
120-
.with_context(|| format!("reading default config at {}", file.display()))?
121-
{
122-
Ok(Some(file))
123-
} else {
124-
Ok(None)
118+
let xdg_dirs =
119+
xdg::BaseDirectories::with_prefix(crate::prog_name!()).context("failed to get xdg dirs")?;
120+
121+
for &filename in &DEFAULT_CONFIG_NAMES {
122+
let file = xdg_dirs.get_config_file(filename);
123+
if file
124+
.try_exists()
125+
.with_context(|| format!("reading default config at {}", file.display()))?
126+
{
127+
return Ok(Some(file));
128+
}
125129
}
130+
131+
Ok(None)
126132
}
127133

128134
impl Config {

0 commit comments

Comments
 (0)