From a8a3bcb6626ce46dcc47317d03e06e714e9e761b Mon Sep 17 00:00:00 2001 From: InioX Date: Fri, 14 Jun 2024 16:28:59 +0200 Subject: [PATCH] feat: add `version_check` setting (#78) --- example/config.toml | 1 + src/main.rs | 14 ++++++++++---- src/util/config.rs | 1 + 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/example/config.toml b/example/config.toml index 21ce667..4ad5bd1 100644 --- a/example/config.toml +++ b/example/config.toml @@ -1,4 +1,5 @@ [config] +# version_check = true set_wallpaper = true wallpaper_tool = 'Swww' prefix = '@' diff --git a/src/main.rs b/src/main.rs index e649d09..81f4a51 100644 --- a/src/main.rs +++ b/src/main.rs @@ -49,11 +49,15 @@ fn main() -> Result<(), Report> { LevelFilter::Debug } else { LevelFilter::Warn - }; + }; + + setup_logging(log_level)?; - setup_logging(log_level)?; + let config: ConfigFile = ConfigFile::read(&args)?; - check_version(); + if config.config.version_check == Some(true) { + check_version(); + } let source_color = get_source_color(&args.source)?; @@ -70,7 +74,6 @@ fn main() -> Result<(), Report> { args.contrast, )); - let config: ConfigFile = ConfigFile::read(&args)?; let default_scheme = args .mode @@ -188,6 +191,9 @@ fn main() -> Result<(), Report> { fn check_version() { let name = env!("CARGO_PKG_NAME"); let current_version = env!("CARGO_PKG_VERSION"); + // for testing + // let current_version = "2.2.0"; + let informer = update_informer::new(registry::Crates, name, current_version); if let Some(version) = informer.check_version().ok().flatten() { diff --git a/src/util/config.rs b/src/util/config.rs index d6e882e..3fe1e16 100644 --- a/src/util/config.rs +++ b/src/util/config.rs @@ -49,6 +49,7 @@ impl CustomColor { #[derive(Serialize, Deserialize, Debug)] pub struct Config { pub reload_apps: Option, + pub version_check: Option, pub reload_apps_list: Option, pub set_wallpaper: Option, pub wallpaper_tool: Option,