Skip to content

Commit

Permalink
feat: add version_check setting (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
InioX committed Jun 14, 2024
1 parent 3379c79 commit a8a3bcb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions example/config.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[config]
# version_check = true
set_wallpaper = true
wallpaper_tool = 'Swww'
prefix = '@'
Expand Down
14 changes: 10 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;

Expand All @@ -70,7 +74,6 @@ fn main() -> Result<(), Report> {
args.contrast,
));

let config: ConfigFile = ConfigFile::read(&args)?;

let default_scheme = args
.mode
Expand Down Expand Up @@ -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() {
Expand Down
1 change: 1 addition & 0 deletions src/util/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ impl CustomColor {
#[derive(Serialize, Deserialize, Debug)]
pub struct Config {
pub reload_apps: Option<bool>,
pub version_check: Option<bool>,
pub reload_apps_list: Option<Apps>,
pub set_wallpaper: Option<bool>,
pub wallpaper_tool: Option<WallpaperTool>,
Expand Down

0 comments on commit a8a3bcb

Please sign in to comment.