Pi66

walrs
pywal but if its Fast-Minimal-Simple
git clone https://git.pi66.xyz/walrs

← back to log

1.0.4

author: pixel
date: 2025-04-05 01:58
hash: 2dbdeb7a4c9c300167546fd6cd685ee15c6232ef

Diffstat:

M

Cargo.toml
2 +-

M

src/main.rs
30 ++++++++++++++++++++++++++++--
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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 {