Pi66

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

← back to log

fix args help problem and change the readme file

author: pixel2175
date: 2025-06-02 16:59
hash: d1585263637f171ad98374842a8b3c5bf991d1b3

Diffstat:

M

README.md
74 ++-------

D

main.rs
245 ------------------------------

M

src/main.rs
21 +++
  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
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
diff --git a/README.md b/README.md
index affb3de..86b00fd 100644
--- a/README.md
+++ b/README.md
@@ -1,65 +1,21 @@
-# Walrs
-Like Pywal, but written in Rust
+<div align="center" style="display: flex; align-items: center; justify-content: center; gap: 20px;">
+  <div align="left">

-## Features
-- Uses the same method as Pywal
-- Fast and minimal (10× faster than Pywal)
-- Better than Wallust in color accuracy, speed, and simplicity
-- Allows customization of brightness and saturation
+  ## walrs
+  #### Like Pywal, but written in Rust
+  walrs is a fast, minimalist CLI tool for generating color schemes from wallpapers.  
+  It works the same as pywal but is written in Rust, making it faster and more efficient.  
+  No external dependencies are required — just an app to set your wallpaper.  

-## Usage
-```bash
-walrs - Generate a colorscheme from an image
+  If you're using pywal, you only need to replace the `wal` command with `walrs`.  
+  Designed for users who prefer simplicity and speed.

-Usage: walrs [OPTIONS]
+  Report issues or bugs on GitHub.  
+  Full documentation and details available at:  
+  [https://pixelll.is-a.dev/tools/walrs](https://pixelll.is-a.dev/tools/walrs)

-Options:
-  -i <IMAGE>                     Path to your wal.png | For random image: path to your wallpapers/
-  -r, --reload             Reload templates and set the wallpaper
-  -R, --Reload                   Reload templates without setting the wallpaper
-  -t, --theme <THEME>            Use an external theme file
-  -g, --generate <GENERATE>      Generate theme and save it in the themes folder (.cache/wal/colorschemes)
-  -s, --saturation <SATURATION>  Specify saturation value (-128 to 127)
-  -b, --brightness <BRIGHTNESS>  Specify brightness value (-128 to 127)
-  -q, --quit                     Enable quit mode (no output)
-      --install-completions      Install completions for the current shell
-  -h, --help                     Print help
-  -V, --version                  Print version
+  </div>

-```
+  <img src="https://pixelll.is-a.dev/static/images/walrs-logo.png" alt="walrs logo" height="200">
+</div>

-## Installation
-- AUR
-```bash
-  yay -S walrs
-```
-- Source
-```bash
-git clone https://github.com/pixel2175/walrs && cd walrs && make install
-```
-
-## Performance
-- Memory: ~3 MB
-- Time: ~290 ms for a 1.5 MB 1080P image
-- Dependencies: Requires an external app to set the wallpaper (feh, xwallpaper, etc.)
-
-### Benchmark
-```bash
-
-time walrs -i ~/.config/wallpaper/
-[I] Generate: generate colors.
-[I] Template: create templates.
-[I] Wallpaper: wallpaper set with feh.
-[I] Terminal: terminal colorscheme set.
-[I] Xrdb: xrdb colorscheme set.
-[I] Colors: colorscheme applied successfully.
-● ● ● ● ● ● ● ● ●
-
-________________________________________________________
-Executed in  376.01 millis    fish           external
-   usr time  236.90 millis    2.05 millis  234.85 millis
-   sys time  132.21 millis    1.04 millis  131.17 millis
-```
-
-If you need any help, reach me on Discord @pi66
-or open an issue
diff --git a/main.rs b/main.rs
deleted file mode 100644
index 447e2dc..0000000
--- a/main.rs
+++ /dev/null
@@ -1,245 +0,0 @@
-mod create_templates;
-mod get_colors;
-mod reload;
-mod theme;
-mod utils;
-mod wallpaper;
-
-use argh::FromArgs;
-use create_templates::create_template;
-use get_colors::get_colors;
-use reload::reload;
-use std::fs::{copy, create_dir_all};
-use std::path::Path;
-use std::process::exit;
-use theme::{collect_themes, set_theme};
-use utils::*;
-
-#[derive(FromArgs)]
-#[argh(description = "walrs - Generate colorscheme from image")]
-struct Arg {
-    #[argh(
-        option,
-        short = 'i',
-        description = "path/to/your/wal.png | path/to/your/wallpapers/"
-    )]
-    image: Option<String>,
-
-    #[argh(
-        option,
-        short = 'k',
-        long = "backend",
-        description = "change the colors backend (walrs -k backends)"
-    )]
-    backend: Option<String>,
-
-    #[argh(
-        switch,
-        short = 'r',
-        description = "reload without changing the wallpaper"
-    )]
-    reload: bool,
-
-    #[argh(
-        switch,
-        short = 'R',
-        long = "reload-nowal",
-        description = "reload with changing the wallpaper"
-    )]
-    reload_nowal: bool,
-
-    #[argh(
-        option,
-        short = 't',
-        long = "theme",
-        description = "use external theme file"
-    )]
-    theme: Option<String>,
-
-    #[argh(
-        option,
-        short = 'g',
-        long = "generate",
-        description = "generate theme in themes folder (.cache/wal/colorschemes)"
-    )]
-    generate: Option<String>,
-
-    #[argh(
-        option,
-        short = 's',
-        long = "saturation",
-        description = "specify the saturation value -128 => 127"
-    )]
-    saturation: Option<i8>,
-
-    #[argh(
-        option,
-        short = 'b',
-        long = "brightness",
-        description = "specify the brightness value -128 => 127"
-    )]
-    brightness: Option<i8>,
-
-    #[argh(
-        switch,
-        short = 'q',
-        long = "quit",
-        description = "set quit mode (no output)"
-    )]
-    quit: bool,
-
-    #[argh(switch, short = 'v', long = "version", description = "version ")]
-    version: bool,
-}
-
-fn image_path(image: Option<String>, send: bool) -> String {
-    match image {
-        Some(ref v) if Path::new(v).exists() => match get_absolute_path(v) {
-            Some(p) => {
-                if Path::new(&p).is_file() {
-                    p
-                } else {
-                    std::str::from_utf8(
-                        &std::process::Command::new("sh")
-                            .arg("-c")
-                            .arg(format!("find \"{}\" -type f | sort -R | head -n1", p))
-                            .output()
-                            .unwrap()
-                            .stdout,
-                    )
-                    .unwrap()
-                    .trim()
-                    .to_string()
-                }
-            }
-            None => {
-                warning("Wallpaper", "Can't find wallpaper absolute path!", send);
-                exit(1);
-            }
-        },
-        Some(_) => {
-            warning("Image", "Image does not exist", send);
-            exit(1);
-        }
-        None => {
-            warning("Image", "Can't find Image", send);
-            exit(1);
-        }
-    }
-}
-
-fn print_themes(send: bool) {
-    let (dark, light) = (collect_themes("dark", send), collect_themes("light", send));
-
-    println!("[\x1b[33mDark\x1b[0m]");
-    for theme in dark {
-        println!("    -{theme}")
-    }
-
-    println!("[\x1b[33mLight\x1b[0m]");
-    for theme in light {
-        println!("    -{theme}")
-    }
-}
-
-fn main() {
-    let arg: Arg = argh::from_env();
-    let backend = match arg.backend {
-        Some(v) => {
-            if v == "backends" {
-                println!(
-                    "┌──────────────────────┬───────────────────────┐  
-│ Method               │ Description           │  
-├──────────────────────┼───────────────────────┤  
-│ kmeans               │ best colors, slow     │  
-│ color_thief          │ balanced              │  
-│ palette_extract      │ fast, weak colors     │  
-│ all                  │ use all methods       │  
-└──────────────────────┴───────────────────────┘"
-                );
-                exit(0)
-            } else {
-                v
-            }
-        }
-        None => "kmeans".to_string(),
-    };
-    if arg.version {
-        info(
-            "Version",
-            &format!("walrs {}", env!("CARGO_PKG_VERSION")),
-            !arg.quit,
-        );
-    }
-
-    if arg.reload_nowal {
-        reload(!arg.quit, true);
-        exit(0);
-    }
-
-    if arg.reload {
-        reload(!arg.quit, false);
-        exit(0);
-    }
-
-    if let Some(v) = arg.theme {
-        if v == "themes" {
-            print_themes(!arg.quit);
-        } else {
-            if get_config(!arg.quit)
-                .join("wal")
-                .join("colorscheme")
-                .exists()
-                || get_config(!arg.quit)
-                    .join("walrs")
-                    .join("colorscheme")
-                    .exists()
-            {
-                set_theme(v, !arg.quit);
-            } else {
-                create_dir_all(&format!(
-                    "{}/walrs/colorschemes",
-                    get_config(!arg.quit).to_string_lossy().to_string()
-                ))
-                .unwrap();
-                run(&format!(
-                    "cp -r /etc/walrs/colorschemes/* {}/walrs/colorschemes",
-                    get_config(!arg.quit).to_string_lossy().to_string()
-                ));
-                set_theme(v, !arg.quit);
-            };
-        }
-        exit(0);
-    }
-
-    if let Some(v) = arg.generate {
-        let dis = get_config(!arg.quit).join("walrs").join("colorschemes");
-        create_dir_all(&dis.join("dark")).unwrap();
-        copy(
-            get_config(!arg.quit).join("wal").join("colors"),
-            dis.join("dark").join(v),
-        )
-        .unwrap();
-        info("Generate", "generate colors", !arg.quit);
-        exit(0);
-    };
-
-    if arg.image.is_some() {
-        let image_path = image_path(arg.image, !arg.quit);
-
-        let palette = get_colors(
-            &image_path,
-            &backend,
-            !arg.quit,
-            arg.brightness,
-            arg.saturation,
-        );
-        info("Generate", "generate colors", !arg.quit);
-
-        create_template(palette, &image_path, !arg.quit);
-        info("Template", "create templates", !arg.quit);
-
-        reload(!arg.quit, true);
-        print_colors(!arg.quit);
-    };
-}
diff --git a/src/main.rs b/src/main.rs
index d01b13f..f5db0a2 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -182,6 +182,27 @@ fn main() {
         exit(0);
     }

+    if arg.image.is_none() && arg.theme.is_none() && arg.generate.is_none() {
+        println!("Usage: walrs [-i <image>] [-k <backend>] [-r] [-R] [-t <theme>] [-g <generate>] [-s <saturation>] [-b <brightness>] [-q] [-v]
+
+walrs - Generate colorscheme from image
+
+Options:
+  -i, --image       path/to/your/wal.png | path/to/your/wallpapers/
+  -k, --backend     change the colors backend (walrs -k backends)
+  -r, --reload      reload without changing the wallpaper
+  -R, --reload-no   reload with changing the wallpaper
+  -t, --theme       use external theme file
+  -g, --generate    generate theme in themes folder (.cache/wal/colorschemes)
+  -s, --saturation  specify the saturation value -128 => 127
+  -b, --brightness  specify the brightness value -128 => 127
+  -q, --quit        set quit mode (no output)
+  -v, --version     version
+  --help, help      display usage information
+");
+        exit(1);
+    }
+
     if let Some(v) = arg.theme {
         if v == "themes" {
             print_themes(!arg.quit);