diff --git a/Cargo.toml b/Cargo.toml
index 01a5b23..d1459d2 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "walrs"
-version = "1.0.3"
+version = "1.0.4"
edition = "2024"
description = "walrs is a fast color scheme generator."
license = "GPL"
diff --git a/src/main.rs b/src/main.rs
index 82270b7..9e7f8c5 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -20,6 +20,11 @@ struct Arg {
#[arg(short = 'i')]
image: Option<String>,
+
+ /// generate colors and save it into .cache/wal
+ #[arg(short = 'g')]
+ generate: Option<String>,
+
/// reload Templates from cache file without set the wallpaper
#[arg(short = 'r', action = ArgAction::SetTrue)]
reload_nowal: bool,
@@ -62,11 +67,32 @@ fn main() {
}
- if arg.image.is_none() {
+ if arg.image.is_none() && arg.generate.is_none() {
let mut cmd = Arg::command();
let _ = cmd.print_help();
+ exit(1);
+ }
- std::process::exit(1);
+ match arg.generate {
+ Some(ref v) if Path::new(v).exists() => match get_absolute_path(v) {
+ Some(p) => {
+ let palette = get_colors(&p, !arg.quit,arg.brightness,arg.saturation);
+ info("Generate", "generate colors", !arg.quit);
+
+ create_template(palette, &p);
+ info("Template", "create templates", !arg.quit);
+ exit(0)
+ },
+ None => {
+ warning("Wallpaper", "Can't find wallpaper absolute path!", !arg.quit);
+ exit(1);
+ }
+ },
+ Some(_) => {
+ warning("Image", "Image does not exist", !arg.quit);
+ exit(1);
+ }
+ None => {}
}
let image_path = match arg.image {