-
Notifications
You must be signed in to change notification settings - Fork 9
/
canvas
executable file
·608 lines (553 loc) · 18.5 KB
/
canvas
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
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
#!/usr/bin/env bash
## Author : Aditya Shakya (adi1090x)
## Mail : adi1090x@gmail.com
## Github : @adi1090x
## Twitter : @adi1090x
## Canvas - An Imagemagick Script To Generate Wallpapers.
## ANSI Colors (FG & BG)
RED="$(printf '\033[31m')" GREEN="$(printf '\033[32m')"
ORANGE="$(printf '\033[33m')" BLUE="$(printf '\033[34m')"
MAGENTA="$(printf '\033[35m')" CYAN="$(printf '\033[36m')"
WHITE="$(printf '\033[37m')" BLACK="$(printf '\033[30m')"
REDBG="$(printf '\033[41m')" GREENBG="$(printf '\033[42m')"
ORANGEBG="$(printf '\033[43m')" BLUEBG="$(printf '\033[44m')"
MAGENTABG="$(printf '\033[45m')" CYANBG="$(printf '\033[46m')"
WHITEBG="$(printf '\033[47m')" BLACKBG="$(printf '\033[40m')"
## Dir, Size, Name, Etc
DIR="`xdg-user-dir PICTURES`/Canvas"
size="1366x768"
psize="500x281"
name="Canvas_$(date +%Y-%m-%d_%I-%M-%S).png"
## Wordsplit in ZSH
set -o shwordsplit 2>/dev/null
## Script Termination
exit_on_signal_SIGINT() {
{ printf "${RED}\n\n%s\n" "[!] Program Interrupted." 2>&1; echo; reset_color; }
exit 0
}
exit_on_signal_SIGTERM() {
{ printf "${RED}\n\n%s\n" "[!] Program Terminated." 2>&1; echo; reset_color; }
exit 0
}
trap exit_on_signal_SIGINT SIGINT
trap exit_on_signal_SIGTERM SIGTERM
## Reset terminal colors
reset_color() {
tput sgr0 # reset attributes
tput op # reset color
return
}
## Prerequisite
Prerequisite() {
dependencies=(convert feh xcolor)
for dependency in "${dependencies[@]}"; do
type -p "$dependency" &>/dev/null || {
echo -e ${RED}"ERROR: Could not find ${GREEN}'${dependency}'${RED}, is it installed?" >&2
{ reset_color; exit 1; }
}
done
if [[ ! -d "$DIR" ]]; then
mkdir -p "$DIR"
fi
}
## Usage
usage() {
clear
cat <<- EOF
${RED}┏━╸${GREEN}┏━┓${ORANGE}┏┓╻${BLUE}╻ ╻${MAGENTA}┏━┓${CYAN}┏━┓${WHITE}
${RED}┃ ${GREEN}┣━┫${ORANGE}┃┗┫${BLUE}┃┏┛${MAGENTA}┣━┫${CYAN}┗━┓${WHITE}
${RED}┗━╸${GREEN}╹ ╹${ORANGE}╹ ╹${BLUE}┗┛ ${MAGENTA}╹ ╹${CYAN}┗━┛${WHITE}
Canvas V3.0 : The Wallpaper Generator.
Developed By : Aditya Shakya (@adi1090x)
Usage : canvas [-h] [-S wxh] [-B] [-s] [-l] [-r] [-t] [-b] [-p] [-n] [-a] [-R]
Options:
-h --help Show this help message & exit
-S --size Size of the wallpaper (default is 1366x768)
-B --blurred Generate a random blurred wallpaper
-s --solid Generate a solid color wallpaper
-l --linear Generate a linear gradient wallpaper
-r --radial Generate a radial gradient wallpaper
-t --twisted Generate a twisted gradient wallpaper
-b --bilinear Generate a bilinear(4point) gradient wallpaper
-p --plasma Generate a plasma wallpaper
-n --no-preview Do not show preview when image is generated
-a --autobg Automatically set as wallpaper (implies -n)
-R --randomize Generate a random wallpaper
EOF
}
## Set wallpaper in kde
set_kde() {
qdbus org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.evaluateScript "
var allDesktops = desktops();
print (allDesktops);
for (i=0;i<allDesktops.length;i++) {
d = allDesktops[i];
d.wallpaperPlugin = 'org.kde.image';
d.currentConfigGroup = Array('Wallpaper',
'org.kde.image',
'General');
d.writeConfig('Image', 'file://"$1"')
}"
}
## Set wallpaper in cinnamon
set_cinnamon() {
gsettings set org.cinnamon.desktop.background picture-uri "file:///$1"
}
## Set wallpaper in GNOME
set_gnome() {
gsettings set org.gnome.desktop.background picture-uri "file:///$1"
gsettings set org.gnome.desktop.screensaver picture-uri "file:///$1"
}
## Choose wallpaper setter
case "$OSTYPE" in
linux*)
if [[ "$XDG_SESSION_TYPE" == 'x11' ]]; then
if [[ "$DESKTOP_SESSION" =~ ^(MATE|Mate|mate)$ ]]; then
SETTER="gsettings set org.mate.background picture-filename"
elif [[ "$DESKTOP_SESSION" =~ ^(Xfce Session|xfce session|XFCE|xfce|Xubuntu|xubuntu)$ ]]; then
SCREEN="$(xrandr --listactivemonitors | awk -F ' ' 'END {print $1}' | tr -d \:)"
MONITOR="$(xrandr --listactivemonitors | awk -F ' ' 'END {print $2}' | tr -d \*+)"
SETTER="xfconf-query --channel xfce4-desktop --property /backdrop/screen$SCREEN/monitor$MONITOR/workspace0/last-image --set"
elif [[ "$DESKTOP_SESSION" =~ ^(LXDE|Lxde|lxde)$ ]]; then
SETTER="pcmanfm --set-wallpaper"
elif [[ "$DESKTOP_SESSION" =~ ^(cinnamon|Cinnamon)$ ]]; then
SETTER=set_cinnamon
elif [[ "$DESKTOP_SESSION" =~ ^(/usr/share/xsessions/plasma|/usr/share/xsessions/plasmax11|NEON|Neon|neon|PLASMA|Plasma|plasma|KDE|Kde|kde)$ ]]; then
SETTER=set_kde
elif [[ "$DESKTOP_SESSION" =~ ^(PANTHEON|Pantheon|pantheon|GNOME|Gnome|gnome|Gnome-xorg|gnome-xorg|gnome-classic|UBUNTU|Ubuntu|ubuntu|DEEPIN|Deepin|deepin|POP|Pop|pop|ZORIN|Zorin|zorin|budgie-desktop)$ ]]; then
SETTER=set_gnome
else
SETTER="feh --bg-fill"
fi
elif [[ "$XDG_SESSION_TYPE" == 'wayland' ]]; then
SETTER="eval ogurictl output '*' --image"
fi
;;
esac
## Display Info
display_info() {
if [[ "$XDG_SESSION_TYPE" == 'x11' ]]; then
echo -e ${ORANGE}"[*] Setting wallpaper in ${GREEN}$XDG_SESSION_TYPE ($DESKTOP_SESSION)${ORANGE} session, using : ${MAGENTA}$SETTER"
elif [[ "$XDG_SESSION_TYPE" == 'wayland' ]]; then
if [[ ! `pidof oguri` ]]; then
echo -e ${RED}"[*] 'oguri' daemon is not running. You must start the daemon first.\n[!] Kill 'swaybg' in sway session if the wallpaper is not getting applied."
exit 1
else
echo -e ${ORANGE}"[*] Setting wallpaper in ${GREEN}$XDG_SESSION_TYPE ($XDG_SESSION_DESKTOP)${ORANGE} session, using : ${MAGENTA}$SETTER"
fi
fi
}
## Wallpaper Setter
set_bg() {
if [[ "$AUTOBG" != "true" ]]; then
{ echo; read -p ${ORANGE}"Set as desktop background? (y/n): "${BLUE}; }
fi
if [[ "$AUTOBG" == "true" ]] || [[ $REPLY == "y" ]] || [[ $REPLY == "Y" ]]; then
$SETTER "$DIR/$name"
{ echo; reset_color; exit 0; }
else
{ echo; reset_color; exit 0; }
fi
}
## Show preview of generated image unless paramaters supplied tells it not
show_feh() {
if [[ "$NOFEH" != "true" ]] && [[ "$AUTOBG" != "true" ]]; then
feh --borderless --scale-down --geometry="$psize" --title="$name" "$DIR/$name" &>/dev/null &
fi
}
## Pick the colors
color_picker() {
picker_app="xcolor --format hex --preview-size 255 --scale 10"
if [[ "$SOLID" == "true" ]]; then
{ echo; echo -n ${ORANGE}"Pick a color... "; }
color=$($picker_app)
{ echo; echo ${ORANGE}"Generating wallpaper with color:${GREEN} $color"; }
elif [[ "$GRADIENT" == "true" ]] || [[ "$RGRADIENT" == "true" ]] || [[ "$TGRADIENT" == "true" ]]; then
{ echo; echo -n ${ORANGE}"Pick first color... "; }
color1=$($picker_app)
{ echo; echo -n ${ORANGE}"Pick second color... "; }
color2=$($picker_app)
color="$color1-$color2"
{ echo; echo ${ORANGE}"Generating wallpaper with colors:${GREEN} $color1, $color2"; }
elif [[ "$BGRADIENT" == "true" ]]; then
{ echo; echo -n ${ORANGE}"Pick first color... "; }
color1=$($picker_app)
{ echo; echo -n ${ORANGE}"Pick second color... "; }
color2=$($picker_app)
{ echo; echo -n ${ORANGE}"Pick third color... "; }
color3=$($picker_app)
{ echo; echo -n ${ORANGE}"Pick fourth color... "; }
color4=$($picker_app)
{ echo; echo ${ORANGE}"Generating wallpaper with colors:${GREEN} $color1, $color2, $color3 & $color4"; }
fi
}
## Show terminal colors
color_prompt() {
f=3 b=4
for j in f b; do
for i in {0..7}; do
printf -v $j$i %b "\e[${!j}${i}m"
done
done
d=$'\e[1m'
t=$'\e[0m'
v=$'\e[7m'
cat <<- EOF
$f1██████ $d██████$t $f2██████ $d██████$t $f3██████ $d██████$t
$f1██01██ $d██02██$t $f2██03██ $d██04██$t $f3██05██ $d██06██$t
$f1██████ $d██████$t $f2██████ $d██████$t $f3██████ $d██████$t
$f4██████ $d██████$t $f5██████ $d██████$t $f6██████ $d██████$t
$f4██07██ $d██08██$t $f5██09██ $d██10██$t $f6██11██ $d██12██$t
$f4██████ $d██████$t $f5██████ $d██████$t $f6██████ $d██████$t
EOF
}
## Fetch colors from .Xresources file
get_xcolors() {
if [[ ! -f "$HOME/.Xresources" ]]; then
{ echo -e ${RED}"\n[!] There's no '.Xresources' file in '$HOME' directory, Exiting...\n"; exit 1; }
fi
x1="$(xrdb -query | grep 'color1:'| awk '{print $NF}')"
x2="$(xrdb -query | grep 'color9:'| awk '{print $NF}')"
x3="$(xrdb -query | grep 'color2:'| awk '{print $NF}')"
x4="$(xrdb -query | grep 'color10:'| awk '{print $NF}')"
x5="$(xrdb -query | grep 'color3:'| awk '{print $NF}')"
x6="$(xrdb -query | grep 'color11:'| awk '{print $NF}')"
x7="$(xrdb -query | grep 'color4:'| awk '{print $NF}')"
x8="$(xrdb -query | grep 'color12:'| awk '{print $NF}')"
x9="$(xrdb -query | grep 'color5:'| awk '{print $NF}')"
x10="$(xrdb -query | grep 'color13:'| awk '{print $NF}')"
x11="$(xrdb -query | grep 'color6:'| awk '{print $NF}')"
x12="$(xrdb -query | grep 'color14:'| awk '{print $NF}')"
xcolors=("$x1" "$x2" "$x3" "$x4" "$x5" "$x6" "$x7" "$x8" "$x9" "$x10" "$x11" "$x12")
color_prompt
if [[ "$SOLID" == "true" ]]; then
{ echo; read -p ${ORANGE}"Enter the color number (without zero): "${BLUE} cnum; }
color="${xcolors[(( cnum -1 ))]}"
{ echo; echo ${ORANGE}"Generating wallpaper with color:${GREEN} $color"; }
elif [[ "$GRADIENT" == "true" ]] || [[ "$RGRADIENT" == "true" ]] || [[ "$TGRADIENT" == "true" ]]; then
{ echo; read -p ${ORANGE}"Enter first color number (without zero): "${BLUE} cnum; }
color1="${xcolors[(( cnum -1 ))]}"
{ echo; read -p ${ORANGE}"Enter second color number (without zero): "${BLUE} cnum; }
color2="${xcolors[(( cnum -1 ))]}"
color="$color1-$color2"
{ echo; echo ${ORANGE}"Generating wallpaper with colors:${GREEN} $color1, $color2"; }
elif [[ "$BGRADIENT" == "true" ]]; then
{ echo; read -p ${ORANGE}"Enter first color number (without zero): "${BLUE} cnum; }
color1="${xcolors[(( cnum -1 ))]}"
{ echo; read -p ${ORANGE}"Enter second color number (without zero): "${BLUE} cnum; }
color2="${xcolors[(( cnum -1 ))]}"
{ echo; read -p ${ORANGE}"Enter third color number (without zero): "${BLUE} cnum; }
color3="${xcolors[(( cnum -1 ))]}"
{ echo; read -p ${ORANGE}"Enter fourth color number (without zero): "${BLUE} cnum; }
color4="${xcolors[(( cnum -1 ))]}"
{ echo; echo ${ORANGE}"Generating wallpaper with colors:${GREEN} $color1, $color2, $color3 & $color4"; }
fi
}
## Get colors
get_color() {
while true; do
{ echo; read -p ${ORANGE}"Pick Colors or Enter Colors or fetch from .Xresources file? (p/e/x): "${BLUE}; }
if [[ $REPLY =~ ^[p/P/e/E/x/X]$ ]]; then
if [[ $REPLY == "p" ]] || [[ $REPLY == "P" ]]; then
color_picker
break
elif [[ $REPLY == "x" ]] || [[ $REPLY == "X" ]]; then
get_xcolors
break
else
if [[ "$SOLID" == "true" ]]; then
{ echo; read -p ${ORANGE}"Enter the color name or hex (eg: teal, #EBCB8B):${GREEN} " color; }
break
elif [[ "$GRADIENT" == "true" ]] || [[ "$RGRADIENT" == "true" ]] || [[ "$TGRADIENT" == "true" ]]; then
{ echo; read -p ${ORANGE}"Enter the colors name or hex (format: color1-color2):${GREEN} " color; }
break
elif [[ "$BGRADIENT" == "true" ]]; then
echo
read -p ${ORANGE}"Enter first color (eg: red, #EC7875):${GREEN} " color1
read -p ${ORANGE}"Enter second color (eg: green, #61C766):${GREEN} " color2
read -p ${ORANGE}"Enter third color (eg: yellow, #FDD835):${GREEN} " color3
read -p ${ORANGE}"Enter fourth color (eg: blue, #42A5F5):${GREEN} " color4
break
fi
fi
else
{ echo ${RED}"[!] Invalid Option, Try Again."; continue; }
fi
done
}
## Generate a solid color wallpaper
solid() {
if [[ "$RANDOMIZE" == "true" ]]; then
get_random_color
color="$RCOLOR"
else
get_color
fi
convert -size "$size" canvas:"$color" "$DIR/$name"
show_feh
set_bg
}
## Generate a linear gradient wallpaper
linear_gradient() {
if [[ "$RANDOMIZE" == "true" ]]; then
get_random_color
color="$RCOLOR"
get_random_number "360"
angle="$RNUM"
else
get_color
{ echo; read -p ${ORANGE}"Enter the rotation angle (default is 0): "${BLUE} angle; }
fi
convert -size "$size" -define gradient:angle="${angle:-0}" gradient:"$color" "$DIR/$name"
show_feh
set_bg
}
## Generate a radial gradient wallpaper
radial_gradient() {
if [[ "$RANDOMIZE" == "true" ]]; then
get_random_color
color1="$RCOLOR"
get_random_color
color="$color1-$RCOLOR"
get_random_number "360"
angle="$RNUM"
getRandomShape
shape="$RSHAPE"
else
get_color
{ echo; read -p ${ORANGE}"Shape? [ 1.diagonal | 2.ellipse | 3.maximum | 4.minimum ] (1/2/3/4): "${BLUE}; }
if [[ $REPLY == "1" ]]; then
shape='diagonal'
elif [[ $REPLY == "2" ]]; then
shape='ellipse'
elif [[ $REPLY == "3" ]]; then
shape='maximum'
elif [[ $REPLY == "4" ]]; then
shape='minimum'
fi
{ echo; read -p ${ORANGE}"Enter the rotation angle (default is 0): "${BLUE} angle; }
fi
convert -size "$size" -define gradient:extent="${shape:-maximum}" -define gradient:angle="${angle:-0}" radial-gradient:"$color" "$DIR/$name"
show_feh
set_bg
}
## Generate a twisted gradient wallpaper
twisted_gradient() {
if [[ "$RANDOMIZE" == "true" ]]; then
get_random_color
color1="$RCOLOR"
get_random_color
color="$color1-$RCOLOR"
get_random_number "500"
twist="$RNUM"
else
get_color
{ echo; read -p ${ORANGE}"Enter the twisting amount (maximum 500): "${BLUE} twist; }
fi
convert -size "$size" gradient:"$color" -swirl "${twist:-150}" "$DIR/$name"
show_feh
set_bg
}
## Generate a 4 point gradient wallpaper
bilinear_gradient() {
if [[ "$RANDOMIZE" == "true" ]]; then
get_random_color
color1="$RCOLOR"
get_random_color
color2="$RCOLOR"
get_random_color
color3="$RCOLOR"
get_random_color
color4="$RCOLOR"
get_random_number "2"
if [[ "$RNUM" == "1" ]]; then
answer="s"
else
answer="r"
fi
else
get_color
{ echo; read -p ${ORANGE}"Smooth or Regular? (s/r): "${BLUE} answer; }
fi
if [[ $answer == "s" ]] || [[ $answer == "S" ]]; then
{ echo; echo -n ${CYAN}"Please wait... "; }
convert \( xc:"$color1" xc:"$color2" +append \) \( xc:"$color3" xc:"$color4" +append \) -append -size "$size" xc: +swap -fx 'v.p{i/(w-1),j/(h-1)}' "$DIR/$name"
else
convert \( xc:"$color1" xc:"$color2" +append \) \( xc:"$color3" xc:"$color4" +append \) -append -filter triangle -resize "$size"\! "$DIR/$name"
fi
show_feh
set_bg
}
## Generate a plasma wallpaper
plasma() {
if [[ "$RANDOMIZE" == "true" ]]; then
get_random_number "3"
if [[ "$RNUM" == "1" ]]; then
answer="r"
elif [[ "$RNUM" == "2" ]]; then
answer="t"
get_random_number "500"
twist="$RNUM"
else
answer="c"
get_random_color
color="$RCOLOR"
fi
else
{ echo; read -p ${ORANGE}"Random, Twisted or Custom colors? (r/t/c): "${BLUE} answer; }
fi
if [[ $answer == "r" ]] || [[ $answer == "R" ]]; then
convert -size "$size" plasma: "$DIR/$name"
elif [[ $answer == "t" ]] || [[ $answer == "T" ]]; then
if [[ "$RANDOMIZE" != "true" ]]; then
{ echo; read -p ${ORANGE}"Enter the twisting amount (maximum 500): "${BLUE} twist; }
fi
convert -size "$size" plasma:fractal -swirl "${twist:-150}" "$DIR/$name"
else
if [[ "$RANDOMIZE" != "true" ]]; then
{ echo; read -p ${ORANGE}"Enter the colors name or hex (format: color1-color2): "${GREEN} color; }
fi
convert -size "$size" plasma:"$color" "$DIR/$name"
fi
show_feh
set_bg
}
## Generate a random, multi-colored blurred/gradient wallpaper
blurred_noise() {
if [[ "$RANDOMIZE" == "true" ]]; then
get_random_number "30"
blur="$RNUM"
else
{ echo; read -p ${ORANGE}"Enter the blur strength (maximum 30): "${BLUE} blur; }
fi
convert -size "100x56" xc: +noise Random "/tmp/noise.png"
convert "/tmp/noise.png" -virtual-pixel tile -blur 0x"${blur:-14}" -auto-level -resize "$size" "$DIR/$name"
show_feh
set_bg
}
## Generate random number lower than giver parameter
get_random_number() {
RNUM=$(( ($RANDOM % $1) + 1 ))
}
## Generate random color
get_random_color() {
RCOLOR="#"
for i in 1 2 3 4 5 6
do
get_random_number "16"
case $RNUM in
"1") NEXTDIGIT="1";;
"2") NEXTDIGIT="2";;
"3") NEXTDIGIT="3";;
"4") NEXTDIGIT="4";;
"5") NEXTDIGIT="5";;
"6") NEXTDIGIT="6";;
"7") NEXTDIGIT="7";;
"8") NEXTDIGIT="8";;
"9") NEXTDIGIT="9";;
"10") NEXTDIGIT="A";;
"11") NEXTDIGIT="B";;
"12") NEXTDIGIT="C";;
"13") NEXTDIGIT="D";;
"14") NEXTDIGIT="E";;
"15") NEXTDIGIT="F";;
"16") NEXTDIGIT="0";;
esac
RCOLOR="$RCOLOR$NEXTDIGIT"
done
}
## Generate random shape option
getRandomShape() {
get_random_number "4"
case $RNUM in
"1") RSHAPE="diagonal";;
"2") RSHAPE="ellipse";;
"3") RSHAPE="maximum";;
"4") RSHAPE="minimum";;
esac
}
## Generate random wallpaper
randomize() {
get_random_number "7"
case $RNUM in
"1") solid;;
"2") linear_gradient;;
"3") radial_gradient;;
"4") twisted_gradient;;
"5") bilinear_gradient;;
"6") plasma;;
"7") blurred_noise;;
esac
}
## Parse the arguments
options=$(getopt -o S:,s,l,r,t,b,p,B,h,a,R,n --long size:,solid,linear,radial,twisted,bilinear,plasma,blurred,help,autobg,randomize,no-preview -- "$@")
eval set -- "$options"
while true; do
case "$1" in
-S|--size)
shift;
size=$1
;;
-s|--solid)
SOLID="true"
COLOR=$1
;;
-l|--linear)
GRADIENT="true"
;;
-r|--radial)
RGRADIENT="true"
;;
-t|--twisted)
TGRADIENT="true"
;;
-b|--bilinear)
BGRADIENT="true"
;;
-p|--plasma)
PLASMA="true"
;;
-B|--blurred)
NOISE="true"
;;
-a|--autobg)
AUTOBG="true"
;;
-R|--randomize)
RANDOMIZE="true"
;;
-n|--no-preview)
NOFEH="true"
;;
-h|--help)
usage
exit
;;
--)
shift
break
;;
esac
shift
done
## Main Execution
Prerequisite
if [[ "$SOLID" == "true" ]]; then
solid
elif [[ "$GRADIENT" == "true" ]]; then
linear_gradient
elif [[ "$RGRADIENT" == "true" ]]; then
radial_gradient
elif [[ "$TGRADIENT" == "true" ]]; then
twisted_gradient
elif [[ "$BGRADIENT" == "true" ]]; then
bilinear_gradient
elif [[ "$PLASMA" == "true" ]]; then
plasma
elif [[ "$NOISE" == "true" ]]; then
blurred_noise
elif [[ "$RANDOMIZE" == "true" ]]; then
randomize
else
usage
fi