From afaab9f54786c5f8abf976663ec751947baa02b1 Mon Sep 17 00:00:00 2001 From: "J. Dekker" Date: Sat, 25 May 2024 00:24:07 +0200 Subject: [PATCH 1/3] flake: add clippy, rust-analyzer, and rustfmt --- flake.nix | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index 54ac76c..343ed43 100644 --- a/flake.nix +++ b/flake.nix @@ -40,10 +40,13 @@ devShells.default = pkgs.mkShell { nativeBuildInputs = with pkgs; [ - rustc cargo - pkg-config + clippy libxkbcommon + pkg-config + rust-analyzer + rustc + rustfmt ]; LD_LIBRARY_PATH = rpath; From ccce5171a4667f57cd78be29d8a48275e4e85719 Mon Sep 17 00:00:00 2001 From: "J. Dekker" Date: Sat, 25 May 2024 00:06:36 +0200 Subject: [PATCH 2/3] config: support yofi.toml filename Allows text-editors to recognise syntax without extra input from the user. --- CHANGELOG.md | 2 ++ src/config.rs | 28 +++++++++++++++++----------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b2f6c2..6313324 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Features +- yofi.toml is now supported. + ## Changes ## Fixes diff --git a/src/config.rs b/src/config.rs index 8665233..449650a 100644 --- a/src/config.rs +++ b/src/config.rs @@ -8,7 +8,10 @@ use serde::Deserialize; use crate::style::{Margin, Padding, Radius}; use crate::Color; -const DEFAULT_CONFIG_NAME: &str = concat!(crate::prog_name!(), ".config"); +const DEFAULT_CONFIG_NAMES: [&str; 2] = [ + concat!(crate::prog_name!(), ".toml"), + concat!(crate::prog_name!(), ".config"), +]; const DEFAULT_ICON_SIZE: u16 = 16; const DEFAULT_FONT_SIZE: u16 = 24; @@ -112,17 +115,20 @@ struct Icon { } fn default_config_path() -> Result> { - let file = xdg::BaseDirectories::with_prefix(crate::prog_name!()) - .context("failed to get xdg dirs")? - .get_config_file(DEFAULT_CONFIG_NAME); - if file - .try_exists() - .with_context(|| format!("reading default config at {}", file.display()))? - { - Ok(Some(file)) - } else { - Ok(None) + let xdg_dirs = + xdg::BaseDirectories::with_prefix(crate::prog_name!()).context("failed to get xdg dirs")?; + + for &filename in &DEFAULT_CONFIG_NAMES { + let file = xdg_dirs.get_config_file(filename); + if file + .try_exists() + .with_context(|| format!("reading default config at {}", file.display()))? + { + return Ok(Some(file)); + } } + + Ok(None) } impl Config { From 35cbd2c4772a91fdd14e5e49a4a4bd63ad6593cc Mon Sep 17 00:00:00 2001 From: "J. Dekker" Date: Mon, 27 May 2024 03:55:56 +0200 Subject: [PATCH 3/3] config: deprecate yofi.config Prints a warning if yofi.config is loaded, please migrate your configurations by renaming yofi.config -> yofi.toml. --- CHANGELOG.md | 2 ++ src/config.rs | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6313324..bd76c07 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ ## Changes +- yofi.config is deprecated. + ## Fixes # 0.2.2 - 2024-03-10 diff --git a/src/config.rs b/src/config.rs index 449650a..2f10962 100644 --- a/src/config.rs +++ b/src/config.rs @@ -118,12 +118,15 @@ fn default_config_path() -> Result> { let xdg_dirs = xdg::BaseDirectories::with_prefix(crate::prog_name!()).context("failed to get xdg dirs")?; - for &filename in &DEFAULT_CONFIG_NAMES { + for (index, &filename) in DEFAULT_CONFIG_NAMES.iter().enumerate() { let file = xdg_dirs.get_config_file(filename); if file .try_exists() .with_context(|| format!("reading default config at {}", file.display()))? { + if index != 0 { + eprintln!("warning: yofi.config is deprecated, please rename your configuration file to yofi.toml"); + } return Ok(Some(file)); } }