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-04 19:38
hash: 177d6d805f68054f4112a90a4c030b96acd05424

Diffstat:

M

src/main.rs
28 ++++++++++++++++++++----------

M

src/reload.rs
10 ++++++-----
 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
diff --git a/src/main.rs b/src/main.rs
index d81c12b..2e2db4f 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -20,7 +20,11 @@ struct Arg {
     #[arg(short = 'i')]
     image: Option<String>,

-    /// reload Templates from cache file
+    /// reload Templates from cache file without set the wallpaper
+    #[arg(short = 'r', action = ArgAction::SetTrue)]
+    reload_nowal: bool,
+
+    /// reload Templates from cache file and set the wallpaper
     #[arg(short = 'R', action = ArgAction::SetTrue)]
     reload: bool,

@@ -46,19 +50,25 @@ struct Arg {
 fn main() {
     let arg = Arg::parse();

-    if !arg.reload && arg.image.is_none() {
-        let mut cmd = Arg::command();
-        let _ = cmd.print_help();
-        
-        std::process::exit(1);
-    }

+    if arg.reload_nowal {
+        reload(!arg.quit,false);
+        exit(0);
+    }

     if arg.reload {
-        reload(!arg.quit);
+        reload(!arg.quit,true);
         exit(0);
     }

+
+    if arg.image.is_none() {
+        let mut cmd = Arg::command();
+        let _ = cmd.print_help();
+
+        std::process::exit(1);
+    }
+
     let image_path = match arg.image {
         Some(ref v) if Path::new(v).exists() => match get_absolute_path(v) {
             Some(p) => p,
@@ -83,7 +93,7 @@ fn main() {
     create_template(palette, &image_path);
     info("Template", "create templates", !arg.quit);

-    reload(!arg.quit);
+    reload(!arg.quit,true);

     print_colors(!arg.quit);
 }
diff --git a/src/reload.rs b/src/reload.rs
index bfbd8e5..b1e5c0a 100644
--- a/src/reload.rs
+++ b/src/reload.rs
@@ -91,7 +91,7 @@ fn colors(colors:Vec<String>,send:bool){
     info("Terminal", "terminal colorscheme set",send);
 }

-pub fn reload(send:bool) {
+pub fn reload(send:bool,set_wal:bool) {
     let cache = get_cache_folder().expect("Can't get cache path");
     let file_path = format!("{}/wal/colors", cache);

@@ -107,10 +107,10 @@ pub fn reload(send:bool) {
         None =>  {warning("Path", "can't found cache folder",send);exit(1)}
     };

-
-    let wallpaper = read_to_string(format!("{}/wal/wal",cache)).expect("run 'cp /etc/walrs/templates/wal ~/.config/walrs/templates/' and restart app").lines().next().unwrap().trim().to_string();
-    wallpaper::change_wallpaper(wallpaper.as_str(),send);
-    
+    if set_wal{
+        let wallpaper = read_to_string(format!("{}/wal/wal",cache)).expect("run 'cp /etc/walrs/templates/wal ~/.config/walrs/templates/' and restart app").lines().next().unwrap().trim().to_string();
+        wallpaper::change_wallpaper(wallpaper.as_str(),send);
+    }
     colors(lines,send);
     xrdb(&cache,send);
     kitty(&cache,send);