5
5
#
6
6
# Copyright (c) 2021 - 2022 xShin
7
7
8
- version=1.0.9
8
+ version=1.1.0
9
9
10
10
XDG_CONFIG_HOME=${XDG_CONFIG_HOME:- ${HOME} / .config}
11
11
config_file=" ${XDG_CONFIG_HOME} /awesomeshot/awesomeshot.conf"
@@ -138,18 +138,62 @@ first_border_color="${hex_color[0]}"
138
138
# NOTE: make sure this value is small, otherwise it will look weird
139
139
first_border_size=7
140
140
141
+ # This variable serves to convert tiny first border (background image) when editing the image,
142
+ # change this value to blank or whatever for disable convert and "yes" for enable function
143
+ convert_first_border=""
144
+
145
+ # This variable serves to set tiny first border color (background image), change this value
146
+ # to "none" for transparent background, if you want to custom the color, you can
147
+ # change this value with hex color or use the one in the array list.
148
+ first_border_color="${hex_color[0]}"
149
+
150
+ # This variable serves to set how many size of the first border
151
+ # NOTE: make sure this value is small, otherwise it will look weird
152
+ first_border_size=7
153
+
141
154
# This variable serves to convert border (background image) when editing the image,
142
155
# change this value to blank or whatever for disable convert and "yes" for enable function
143
156
convert_second_border="yes"
144
157
145
158
# This variable serves to set border color (background image), change this value
146
159
# to "none" for transparent background, if you want to custom the color, you can
147
160
# change this value with hex color or use the one in the array list.
148
- second_border_color="${hex_color[0]}"
161
+ # NOTE: if convert_second_border enable and second_border_color value not none
162
+ # will be conflict
163
+ #second_border_color="${hex_color[0]}"
164
+ second_border_color="none"
149
165
150
166
# This variable serves to set how many size of the second border
151
167
second_border_size=50
152
168
169
+ # This variable serves to convert border with gradient color,
170
+ # change this value to blank or whatever for disable convert and "yes" for enable function
171
+ convert_second_border_gradient="yes"
172
+
173
+ # This variable serves to convert gradient color method
174
+ # More information: https://legacy.imagemagick.org/Usage/misc/
175
+ # List available method:
176
+ # - saddle
177
+ # - mesh
178
+ interpolate_method="saddle"
179
+
180
+ second_border_gradient_color=(
181
+ "#C850C0"
182
+ "#FFCC70"
183
+ "#4158D0"
184
+ "#FE7FAA"
185
+ )
186
+
187
+ saddle_color_top_left="${second_border_gradient_color[0]}"
188
+ saddle_color_top_right="${second_border_gradient_color[1]}"
189
+ saddle_color_bottom_left="${second_border_gradient_color[2]}"
190
+ saddle_color_bottom_right="${second_border_gradient_color[0]}"
191
+
192
+ mesh_color_top_left="${second_border_gradient_color[1]}"
193
+ mesh_color_top_right="${second_border_gradient_color[1]}"
194
+ mesh_color_bottom_left="${second_border_gradient_color[3]}"
195
+ mesh_color_bottom_right="${second_border_gradient_color[3]}"
196
+
153
197
# This variable serves to convert the shadow of image, change this value
154
198
# to blank or whatever for disable function and "yes" for enable function.
155
199
convert_shadow="yes"
@@ -213,8 +257,9 @@ footer_background="none"
213
257
open_image=""
214
258
EOF
215
259
216
- # init file_name
260
+ # init
217
261
file_name=" "
262
+ interpolate_file_name=" "
218
263
219
264
function getUserConfig() {
220
265
@@ -230,6 +275,8 @@ function getUserConfig() {
230
275
231
276
fi
232
277
278
+ checkConfig
279
+
233
280
}
234
281
235
282
function generateDefaultConfig() {
@@ -337,6 +384,10 @@ function autoRun() {
337
384
if [ " ${convert_second_border} " == " yes" ]; then
338
385
convertSecondBorder
339
386
fi
387
+
388
+ if [ " ${convert_second_border_gradient} " == " yes" ]; then
389
+ convertSecondBorderGradient
390
+ fi
340
391
341
392
if [ " ${convert_footer} " == " yes" ]; then
342
393
convertFooter
@@ -514,7 +565,7 @@ function convertTitleBar(){
514
565
}
515
566
516
567
function convertTitleBarText() {
517
- subtitle " [+]*Set*Title*Bar*Text"
568
+ subtitle " [+]*Set*Title*Bar*Text* "
518
569
519
570
echo -n " ${titlebar_text} " |
520
571
convert " ${file_name} " \
@@ -571,8 +622,54 @@ function convertSecondBorder() {
571
622
check
572
623
}
573
624
625
+ function interpolateSaddle() {
626
+ interpolate_file_name=" interpolate_saddle"
627
+ convert \
628
+ \( \
629
+ xc:${saddle_color_top_left} xc:${saddle_color_top_right} +append \
630
+ \) \
631
+ \( \
632
+ xc:${saddle_color_bottom_left} xc:${saddle_color_bottom_right} +append \
633
+ \) -append -size $size_wh \
634
+ xc: +swap -fx ' v.p{i/(w-1),j/(h-1)}' \
635
+ ${XDG_CONFIG_HOME} /awesomeshot/backgrad/${interpolate_file_name} .png
636
+ }
637
+
638
+ function interpolateMesh() {
639
+ interpolate_file_name=" interpolate_mesh"
640
+ convert \
641
+ \( \
642
+ xc:${mesh_color_top_left} xc:${mesh_color_top_right} +append \
643
+ \) \
644
+ \( \
645
+ xc:${mesh_color_bottom_left} xc:${mesh_color_bottom_right} +append \
646
+ \) -append -size ${size_wh} \
647
+ xc: +swap -interpolate Mesh -fx ' v.p{i/(w-1),j/(h-1)}' \
648
+ ${XDG_CONFIG_HOME} /awesomeshot/backgrad/${interpolate_file_name} .png
649
+ }
650
+
651
+ function convertSecondBorderGradient() {
652
+ subtitle " [+]*Set*Image*Second*Border*Gradient*"
653
+ size_wh=$( identify -format %wx%h $file_name )
654
+ if [ ! -d " ${XDG_CONFIG_HOME} /awesomeshot/backgrad" ]; then
655
+ mkdir ${XDG_CONFIG_HOME} /awesomeshot/backgrad
656
+ fi
657
+
658
+ case ${interpolate_method} in
659
+ " saddle" |" Saddle" )
660
+ interpolateSaddle
661
+ ;;
662
+ " mesh" |" Mesh" )
663
+ interpolateMesh
664
+ ;;
665
+ esac
666
+
667
+ composite -gravity center " $file_name " ${XDG_CONFIG_HOME} /awesomeshot/backgrad/${interpolate_file_name} .png " $file_name "
668
+ check
669
+ }
670
+
574
671
function convertFooter() {
575
- subtitle " [+]*Set*Image*Footer"
672
+ subtitle " [+]*Set*Image*Footer* "
576
673
echo -n " ${footer_text} " |
577
674
convert " $file_name " \
578
675
-gravity ${footer_position} \
@@ -604,15 +701,15 @@ function stat() {
604
701
605
702
if [ " ${2} " == " Success" ]; then
606
703
607
- echo -e " [ ${COLOR_SUCCESS}${1}${COLOR_DEFAULT} ] > ${3} "
704
+ echo -e " [ ${COLOR_SUCCESS}${1}${COLOR_DEFAULT} ]\n ${COLOR_SUCCESS} |\n ╰─ ${COLOR_DEFAULT} ${3} "
608
705
609
706
elif [ " ${2} " == " Warning" ]; then
610
707
611
- echo -e " [ ${COLOR_WARNING}${1}${COLOR_DEFAULT} ] > ${3} "
708
+ echo -e " [ ${COLOR_WARNING}${1}${COLOR_DEFAULT} ]\n ${COLOR_WARNING} |\n ╰─ ${COLOR_DEFAULT} ${3} "
612
709
613
710
elif [ " ${2} " == " Danger" ]; then
614
711
615
- echo -e " [ ${COLOR_DANGER}${1}${COLOR_DEFAULT} ] > ${3} "
712
+ echo -e " [ ${COLOR_DANGER}${1}${COLOR_DEFAULT} ]\n ${COLOR_DANGER} |\n ╰─ ${COLOR_DEFAULT} ${3} "
616
713
617
714
fi
618
715
@@ -736,6 +833,15 @@ function help() {
736
833
737
834
second_border_size This variable serves to set how many size of the second border
738
835
836
+ convert_second_border_gradient This variable severs to convert border with gradient color,
837
+ change this value to blank or whatever for disable convert and 'yes' for enable function
838
+
839
+ interpolate_method This variable serves to convert gradient color method
840
+ More information: https://legacy.imagemagick.org/Usage/misc/
841
+ List available method:
842
+ - saddle
843
+ - mesh
844
+
739
845
convert_shadow This variable serves to convert the shadow of image, change this value
740
846
to blank or whatever for disable function and 'yes' for enable function.
741
847
@@ -792,6 +898,18 @@ function version() {
792
898
echo -e " awesomeshot v.${version} "
793
899
}
794
900
901
+ function checkConfig() {
902
+ if [[ $convert_second_border == " yes" && $convert_second_border_gradient == " yes" ]]; then
903
+ if [ $second_border_color != " none" ]; then
904
+ stat " ERROR" " Danger" " Conflict detected on config '${COLOR_WARNING} convert_second_border${COLOR_DEFAULT} ' and '${COLOR_WARNING} convert_second_border_gradient${COLOR_DEFAULT} ' enable at the same time"
905
+ echo -e "
906
+ both variable can be enable if '${COLOR_WARNING} second_border_color${COLOR_DEFAULT} ' value is none
907
+ "
908
+ exit 1
909
+ fi
910
+ fi
911
+ }
912
+
795
913
case " ${1} " in
796
914
-a|--auto )
797
915
main autoRun
0 commit comments