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 | diff --git a/autocomplete.sh b/autocomplete.sh
index c6fe7ce..41c208e 100755
--- a/autocomplete.sh
+++ b/autocomplete.sh
@@ -24,15 +24,16 @@ case "$CURRENT_SHELL" in
complete -c walrs -e
# Basic flags
-complete -c walrs -s i -l image -d "path to image or wallpapers directory" -r -F
-complete -c walrs -s k -l backend -d "change the colors backend" -x -a "kmeans color_thief palette_extract all backends"
+complete -c walrs -s i -l image -d "path to image or directory" -r -F
complete -c walrs -s r -l reload -d "reload without changing the wallpaper"
-complete -c walrs -s R -l reload-no -d "reload with changing the wallpaper"
-complete -c walrs -s t -l theme -d "use external theme file" -r -F
-complete -c walrs -s g -l generate -d "generate theme in themes folder" -x
-complete -c walrs -s s -l saturation -d "saturation value -128 to 127" -x
-complete -c walrs -s b -l brightness -d "brightness value -128 to 127" -x
-complete -c walrs -s q -l quit -d "set quit mode (no output)"
+complete -c walrs -s R -l reload-no -d "will be removed in the next update; use -w instead"
+complete -c walrs -s t -l theme -d "use external theme file from .config/walrs/colorschemes" -r -F
+complete -c walrs -s g -l generate -d "generate & save theme to .config/walrs/colorschemes" -x
+complete -c walrs -s s -l saturation -d "set saturation value (-128 to 127)" -x
+complete -c walrs -s b -l brightness -d "set brightness value (-128 to 127)" -x
+complete -c walrs -s S -l scripts -d "skip running scripts in ~/.config/walrs/scripts/"
+complete -c walrs -s W -l walless -d "skip changing the wallpaper"
+complete -c walrs -s q -l quiet -d "set quit mode (no output)"
complete -c walrs -s v -l version -d "show version"
complete -c walrs -l help -d "display help"
complete -c walrs -a help -d "display help"
@@ -62,16 +63,17 @@ _walrs() {
typeset -A opt_args
_arguments \
- '(-i --image)'{-i,--image}'[path to image or wallpapers directory]:image file:_files -g "*.{jpg,jpeg,png,bmp,gif,tiff,webp}(-.)"' \
- '(-k --backend)'{-k,--backend}'[change the colors backend]:backend:(kmeans color_thief palette_extract all backends)' \
+ '(-i --image)'{-i,--image}'[path to image or directory]:image file:_files -g "*.{jpg,jpeg,png,bmp,gif,tiff,webp}(-.)"' \
'(-r --reload)'{-r,--reload}'[reload without changing the wallpaper]' \
- '(-R --reload-no)'{-R,--reload-no}'[reload with changing the wallpaper]' \
- '(-t --theme)'{-t,--theme}'[use external theme file]:theme file:_files -g "*.json(-.)"' \
- '(-g --generate)'{-g,--generate}'[generate theme in themes folder]:theme name:' \
- '(-s --saturation)'{-s,--saturation}'[specify the saturation value -128 => 127]:saturation:({-128..127})' \
- '(-b --brightness)'{-b,--brightness}'[specify the brightness value -128 => 127]:brightness:({-128..127})' \
- '(-q --quit)'{-q,--quit}'[set quit mode (no output)]' \
- '(-v --version)'{-v,--version}'[version]' \
+ '(-R --reload-no)'{-R,--reload-no}'[will be removed in the next update; use -w instead]' \
+ '(-t --theme)'{-t,--theme}'[use external theme file from .config/walrs/colorschemes]:theme file:_files -g "*.json(-.)"' \
+ '(-g --generate)'{-g,--generate}'[generate & save theme to .config/walrs/colorschemes]:theme name:' \
+ '(-s --saturation)'{-s,--saturation}'[set saturation value (-128 to 127)]:saturation:({-128..127})' \
+ '(-b --brightness)'{-b,--brightness}'[set brightness value (-128 to 127)]:brightness:({-128..127})' \
+ '(-S --scripts)'{-S,--scripts}'[skip running scripts in ~/.config/walrs/scripts/]' \
+ '(-W --walless)'{-W,--walless}'[skip changing the wallpaper]' \
+ '(-q --quiet)'{-q,--quiet}'[set quit mode (no output)]' \
+ '(-v --version)'{-v,--version}'[show version]' \
'(--help)--help[display usage information]'
}
@@ -111,7 +113,7 @@ _walrs_completion() {
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
- opts="-i --image -k --backend -r --reload -R --reload-no -t --theme -g --generate -s --saturation -b --brightness -q --quit -v --version --help help"
+ opts="-i --image -r --reload -R --reload-no -t --theme -g --generate -s --saturation -b --brightness -S --scripts -W --walless -q --quiet -v --version --help help"
case ${prev} in
-i|--image)
@@ -119,10 +121,6 @@ _walrs_completion() {
COMPREPLY+=( <math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow><mo stretchy="false">(</mo><mi>c</mi><mi>o</mi><mi>m</mi><mi>p</mi><mi>g</mi><mi>e</mi><mi>n</mi><mo>−</mo><mi>d</mi><mo>−</mo><mo>−</mo><mi>"</mi></mrow></math>{cur}") )
return 0
;;
- -k|--backend)
- COMPREPLY=( <math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow><mo stretchy="false">(</mo><mi>c</mi><mi>o</mi><mi>m</mi><mi>p</mi><mi>g</mi><mi>e</mi><mi>n</mi><mo>−</mo><mi>W</mi><mi>"</mi><mi>k</mi><mi>m</mi><mi>e</mi><mi>a</mi><mi>n</mi><mi>s</mi><mi>c</mi><mi>o</mi><mi>l</mi><mi>o</mi><msub><mi>r</mi><mi>t</mi></msub><mi>h</mi><mi>i</mi><mi>e</mi><mi>f</mi><mi>p</mi><mi>a</mi><mi>l</mi><mi>e</mi><mi>t</mi><mi>t</mi><msub><mi>e</mi><mi>e</mi></msub><mi>x</mi><mi>t</mi><mi>r</mi><mi>a</mi><mi>c</mi><mi>t</mi><mi>a</mi><mi>l</mi><mi>l</mi><mi>b</mi><mi>a</mi><mi>c</mi><mi>k</mi><mi>e</mi><mi>n</mi><mi>d</mi><mi>s</mi><mi>"</mi><mo>−</mo><mo>−</mo><mi>"</mi></mrow></math>{cur}") )
- return 0
- ;;
-t|--theme)
COMPREPLY=( <math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow><mo stretchy="false">(</mo><mi>c</mi><mi>o</mi><mi>m</mi><mi>p</mi><mi>g</mi><mi>e</mi><mi>n</mi><mo>−</mo><mi>f</mi><mo>−</mo><msup><mi>X</mi><mi>′</mi></msup><mo>!</mo><mo>*</mo><mo>.</mo><mi>j</mi><mi>s</mi><mi>o</mi><msup><mi>n</mi><mi>′</mi></msup><mo>−</mo><mo>−</mo><mi>"</mi></mrow></math>{cur}") )
return 0
@@ -144,9 +142,8 @@ _walrs_completion() {
complete -F _walrs_completion walrs
EOF
-
echo "source ~/.local/share/bash-completion/completions/walrs" >> ~/.bashrc
- echo -e "Bash completion installed to: <math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow><mi>C</mi><mi>O</mi><mi>M</mi><mi>P</mi><mi>L</mi><mi>E</mi><mi>T</mi><mi>I</mi><mi>O</mi><msub><mi>N</mi><mi>D</mi></msub><mi>I</mi><mi>R</mi><mo>/</mo><mi>w</mi><mi>a</mi><mi>l</mi><mi>r</mi><mi>s</mi></mrow></math>"
+ echo -e "Bash completion installed to: $COMPLETION_DIR/walrs"
;;
*)
diff --git a/src/main.rs b/src/main.rs
index 7b88527..a1ee538 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -17,32 +17,21 @@ 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/ | this will change the wallpaper"
- )]
+ #[argh(option, short = 'i', description = "path to image or directory")]
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-no",
- description = "this will removed next update use -w instead"
+ description = "will be removed in the next update; use -w instead"
)]
reload_no: bool,
@@ -50,7 +39,7 @@ struct Arg {
option,
short = 't',
long = "theme",
- description = "use external theme file"
+ description = "use external theme file from .config/walrs/colorschemes"
)]
theme: Option<String>,
@@ -58,7 +47,7 @@ struct Arg {
option,
short = 'g',
long = "generate",
- description = "generate theme in themes folder (.cache/wal/colorschemes)"
+ description = "generate & save theme to .config/walrs/colorschemes"
)]
generate: Option<String>,
@@ -66,7 +55,7 @@ struct Arg {
option,
short = 's',
long = "saturation",
- description = "specify the saturation value -128 => 127"
+ description = "set saturation value (-128 to 127)"
)]
saturation: Option<i8>,
@@ -74,7 +63,7 @@ struct Arg {
option,
short = 'b',
long = "brightness",
- description = "specify the brightness value -128 => 127"
+ description = "set brightness value (-128 to 127)"
)]
brightness: Option<i8>,
@@ -82,40 +71,37 @@ struct Arg {
switch,
short = 'S',
long = "scripts",
- description = "this will skip runing the scripts in ~/.config/walrs/scripts/"
+ description = "skip running scripts in ~/.config/walrs/scripts/"
)]
run_scripts: Option<bool>,
#[argh(
switch,
short = 'W',
- long = "wallpaperless",
- description = "this will skip changing the wallpaper"
+ long = "walless",
+ description = "skip changing the wallpaper"
)]
- wallpaperless: Option<bool>,
+ walless: Option<bool>,
#[argh(
switch,
short = 'q',
- long = "quit",
+ long = "quiet",
description = "set quit mode (no output)"
)]
quit: bool,
- #[argh(switch, short = 'v', long = "version", description = "version ")]
+ #[argh(switch, short = 'v', long = "version", description = "show version")]
version: bool,
}
fn main() {
// get and load args from user
let arg: Arg = argh::from_env();
+
// save the quit status
let send = !arg.quit;
- // save the backend
- let backend = match arg.backend {
- Some(v) => v,
- None => "all".to_string(),
- };
+
// print the version
if arg.version {
info("Version", env!("CARGO_PKG_VERSION"), send);
@@ -126,7 +112,7 @@ fn main() {
if arg.reload_no {
warning(
"Reload",
- "this will be removed in the next update, use -W instead\n",
+ "this will be removed in the next update, use -W instead",
send,
);
reload(send, true, arg.run_scripts.unwrap_or(false));
@@ -137,7 +123,7 @@ fn main() {
if arg.reload {
reload(
send,
- arg.wallpaperless.unwrap_or(false),
+ arg.walless.unwrap_or(false),
arg.run_scripts.unwrap_or(false),
);
exit(0);
@@ -190,16 +176,15 @@ fn main() {
// analyze the image and generate the palette
if arg.image.is_some() {
let image_path = image_path(arg.image, send);
- let palette = get_colors(&image_path, &backend, send, arg.brightness, arg.saturation);
+ let palette = get_colors(&image_path, send, arg.brightness, arg.saturation);
info("Generate", "generate colors", send);
create_template(palette, &image_path, send);
info("Template", "create templates", send);
- // change_wallpaper(&image_path, send);
reload(
send,
- arg.wallpaperless.unwrap_or(false),
+ arg.walless.unwrap_or(false),
arg.run_scripts.unwrap_or(false),
);
print_colors(send);
|