diff --git a/awesomeshot b/awesomeshot index d52b36b..116a50c 100755 --- a/awesomeshot +++ b/awesomeshot @@ -5,7 +5,7 @@ # # Copyright (c) 2021 - 2022 xShin -version=1.0.5 +version=1.0.8 XDG_CONFIG_HOME=${XDG_CONFIG_HOME:-${HOME}/.config} config_file="${XDG_CONFIG_HOME}/awesomeshot/awesomeshot.conf" @@ -26,8 +26,8 @@ read -rd '' config <<'EOF' # PATH is same with this variable. Default my phone result file # image PATH on "/sdcard/DCIM/Screenshots". If not same, # you can edit this variable value -#screenshot_result_path="/sdcard/Pictures/ScreenMaster" -screenshot_result_path="/sdcard/DCIM/Screenshots" +screenshot_result_path="/sdcard/Pictures/ScreenMaster" +#screenshot_result_path="/sdcard/DCIM/Screenshots" # This variable serves to set the convert image with file type non PNG, change this value # to blank or whatever for disable function and "yes" for enable function. @@ -84,17 +84,30 @@ convert_rounded="yes" # This variable serves to set how many rounded corners border_radius=10 +# This variable serves to convert tiny first border (background image) when editing the image, +# change this value to blank or whatever for disable convert and "yes" for enable function +convert_first_border="yes" + +# This variable serves to set tiny first border color (background image), change this value +# to "none" for transparent background, if you want to custom the color, you can +# change this value with hex color or use the one in the array list. +first_border_color="${hex_color[0]}" + +# This variable serves to set how many size of the first border +# NOTE: make sure this value is small, otherwise it will look weird +first_border_size=7 + # This variable serves to convert border (background image) when editing the image, # change this value to blank or whatever for disable convert and "yes" for enable function -convert_border="yes" +convert_second_border="yes" # This variable serves to set border color (background image), change this value # to "none" for transparent background, if you want to custom the color, you can # change this value with hex color or use the one in the array list. -border_color="${hex_color[0]}" +second_border_color="${hex_color[0]}" -# This variable serves to set how many size of the border -border_size=50 +# This variable serves to set how many size of the second border +second_border_size=50 # This variable serves to convert the shadow of image, change this value # to blank or whatever for disable function and "yes" for enable function. @@ -268,12 +281,17 @@ function autoRun() { convertRounded fi + if [ "${convert_first_border}" == "yes" ]; then + convertFirstBorder + convertRounded + fi + if [ "${convert_shadow}" == "yes" ]; then convertShadow fi - if [ "${convert_border}" == "yes" ]; then - convertBorder + if [ "${convert_second_border}" == "yes" ]; then + convertSecondBorder fi if [ "${convert_footer}" == "yes" ]; then @@ -281,7 +299,7 @@ function autoRun() { fi termux-media-scan "${file_name}" &> /dev/null - termux-toast -b "${border_color}" -c "${footer_foreground}" -g top "${file_name##*/} ✅" + termux-toast -b "${hex_color[0]}" -c "${hex_color[1]}" -g top "${file_name##*/} ✅" termux-notification --action "termux-open '${file_name}'" --icon "camera_enhance" \ --image-path "${file_name}" --priority "high" --title "📸 Awesomeshot v${version}" @@ -297,6 +315,10 @@ function autoRun() { done } +function getPwd() { + pwd=$(pwd) +} + function manualRun() { getUserConfig header @@ -306,12 +328,12 @@ function manualRun() { check if [ "${convert_to_png}" == "yes" ]; then - convertToPng "${get_file_name}" + convertToPng fi if [ "${backup}" == "yes" ]; then title "${COLOR_SKY}[+] BACKUP IMAGE${COLOR_DEFAULT}" - backupOriginalPhoto "${get_file_name}" + backupOriginalPhoto "${file_name}" fi title "${COLOR_SKY}[+] EDITING IMAGE${COLOR_DEFAULT}" @@ -324,12 +346,17 @@ function manualRun() { convertRounded fi + if [ "${convert_first_border}" == "yes" ]; then + convertFirstBorder + convertRounded + fi + if [ "${convert_shadow}" == "yes" ]; then convertShadow fi - if [ "${convert_border}" == "yes" ]; then - convertBorder + if [ "${convert_second_border}" == "yes" ]; then + convertSecondBorder fi if [ "${convert_footer}" == "yes" ]; then @@ -337,7 +364,7 @@ function manualRun() { fi termux-media-scan "${file_name}" &> /dev/null - termux-toast -b "${border_color}" -c "${footer_foreground}" -g top "${file_name##*/} ✅" + termux-toast -b "${hex_color[0]}" -c "${hex_color[1]}" -g top "${file_name} ✅" termux-notification --action "termux-open '${file_name}'" --icon "camera_enhance" \ --image-path "${file_name}" --priority "high" --title "📸 Awesomeshot v${version}" @@ -354,14 +381,15 @@ function manualRun() { function backupOriginalPhoto() { change_filename_backup=$(echo $1 | sed 's/.png/_backup.png/g') + get_filename_suffix=${change_filename_backup##*/} if [ ! -d ${path_backup} ]; then mkdir -p "${path_backup}" fi - cp "${file_name}" "${path_backup}/${change_filename_backup}" + cp "${file_name}" "${path_backup}/${get_filename_suffix}" - if [ -f ${path_backup}/${change_filename_backup} ]; then + if [ -f ${path_backup}/${get_filename_suffix} ]; then subtitle "[+]*Backup*File*" check @@ -451,6 +479,13 @@ function convertRounded() { check } +function convertFirstBorder() { + subtitle "[+]*Set*Image*First*Border*Color*" + + convert "$file_name" -bordercolor "${first_border_color}" -border ${first_border_size} "$file_name" + check +} + function convertShadow() { subtitle "[+]*Set*Image*Shadow*" @@ -467,10 +502,10 @@ function convertShadow() { check } -function convertBorder() { - subtitle "[+]*Set*Image*Border*Color*" +function convertSecondBorder() { + subtitle "[+]*Set*Image*Second*Border*Color*" - convert "$file_name" -bordercolor "${border_color}" -border ${border_size} "$file_name" + convert "$file_name" -bordercolor "${second_border_color}" -border ${second_border_size} "$file_name" check } @@ -536,13 +571,125 @@ function help() { awesomeshot [args] [file] META OPTIONS: - -h, --help Show list of command-line options - -v, --version Show version of awesomeshot + -h, --help Show list of command-line options + -v, --version Show version of awesomeshot RUN OPTIONS: - -a, --auto Run awesomeshot with automatic while take screenshot - -m, --manual Run awesomeshot with manual (this option require filename) - -c, --config Generate default config awesomeshot.conf + -a, --auto Run awesomeshot with automatic while take screenshot + -m, --manual Run awesomeshot with manual (this option require filename) + -c, --config Generate default config awesomeshot.conf + + CONFIG OPTIONS: + screenshot_result_path Make sure when your phone screenshot the result file image + PATH is same with this variable. Default my phone result file + image PATH on '/sdcard/DCIM/Screenshots'. If not same, + you can edit this variable value + + convert_to_png This variable serves to set the convert image with file type non PNG, change this value + to blank or whatever for disable function and 'yes' for enable function. + Convert to PNG if file not PNG + + backup This variable serves to function to backup original photo + (screenshot result), change this value to blank or whatever for disable + function and 'yes' for enable function + + path_backup This variable serves to set the original photo backup PATH + + hex_color Array Hex Color + + convert_titlebar This variable serves to convert title bar when editing the image, change this value + to blank or whatever for disable convert and 'yes' for enable function + + add_on_img This variable serves to set where the title bar place, if 'yes' the title bar add on image, + if blank or whatever the title bar will be added at out of image + + width_img & height_img This variable serves to set the width and height size of title bar. + NOTE (Bug Found): + - Sometimes the title bar result is too big or too small + width_img=magick file_name - format '%w' info: + height_img=magick file_name - format '%h' info: + if (( width_img > height_img )); then + height_img=width_img + elif (( width_img < height_img )); then + width_img=height_img + fi + + titlebar_color This variable serves to set titlebar color, if you want to custom the color, you can + change this value with hex color or use the one in the array list. + + convert_rounded This variable serves to convert rounded corner, change this value + to blank or whatever for disable convert and 'yes' for enable function + + border_radius This variable serves to set how many rounded corners + + convert_first_border This variable serves to convert tiny first border (background image) when editing the image, + change this value to blank or whatever for disable convert and 'yes' for enable function + + first_border_color This variable serves to set tiny first border color (background image), change this value + to 'none' for transparent background, if you want to custom the color, you can + change this value with hex color or use the one in the array list. + + first_border_size This variable serves to set how many size of the first border + NOTE: make sure this value is small, otherwise it will look weird + + convert_second_border This variable serves to convert border (background image) when editing the image, + change this value to blank or whatever for disable convert and 'yes' for enable function + + second_border_color This variable serves to set border color (background image), change this value + to 'none' for transparent background, if you want to custom the color, you can + change this value with hex color or use the one in the array list. + + second_border_size This variable serves to set how many size of the second border + + convert_shadow This variable serves to convert the shadow of image, change this value + to blank or whatever for disable function and 'yes' for enable function. + + shadow_color This variable serves to set shadow color, if you want to custom the color, you can + change this value with hex color or use the one in the array list. + + shadow_size This variable serves to set shadow size, this variable has four values: + shadow_size='75x30+0+30' + that mean: + - bottom shadow is x75 + - right shadow is +30 + - top shadow is +0 + - left shadow is +30 + + convert_footer This variable serves to convert the footer text, change this value + to blank or whatever for disable function and 'yes' for enable function. + + footer_text This variable serves to set text of footer, if you want to use icon + you can search on Nerd Fonts Website (https://www.nerdfonts.com/cheat-sheet) + NOTE: if you use icon from Nerd Fonts, make sure 'footer_font' using nerd fonts to! + + footer_position This variable serves to set text position of footer, the value contain 8 wind direction: + - NorthWest + - North + - West + - Center + - East + - SouthWest + - South + - SouthEast + NOTE: Default value is 'South' + + footer_xy This variable serves to set position of 'X' and 'Y' + + footer_font This variable serves to set the font used when converting, you can check the list font + available to use for ImageMagick by command: + magick convert -list font | grep -iE 'font:.*' + + footer_font_size This variable serves to set font size + + footer_foreground This variable serves to set the text color, if you want to custom the color, you can + change this value with hex color or use the one in the array list. + + footer_background This variable serves to set footer background color (background text), change this value + to 'none' for transparent background, if you want to custom the color, you can + change this value with hex color or use the one in the array list. + + open_image This variable serves to open the result of image (when editing finished), change this value + to blank or whatever for disable function and 'yes' for enable function. " } @@ -559,7 +706,8 @@ case "${1}" in ;; -m|--manual ) if [ ${2} ]; then - file_name="${2}" + getPwd + file_name="${pwd}/${2}" main manualRun else echo "" diff --git a/awesomeshot.1 b/awesomeshot.1 index 2559b09..e13c4f8 100644 --- a/awesomeshot.1 +++ b/awesomeshot.1 @@ -1,4 +1,4 @@ -.TH AWESOMESHOT 1 "18 April 2022" "Awesomeshot 1.0.5" "User Commands" +.TH AWESOMESHOT 1 "20 April 2022" "Awesomeshot 1.0.8" "User Commands" .SH NAME Awesomeshot .SH SYNOPSIS @@ -6,6 +6,18 @@ Awesomeshot \fI\,[args] [file]\/\fR .SH DESCRIPTION Awesomeshot \- A command-line screenshot tool written in bash 5.1.16+ +.SH "HOW AWESOMESHOT WORK?" +\fI\,https://github.com/mayTermux/awesomeshot/issues/2#issuecomment-1052047095\/\fR +.SH "WIKI OR DOCS" +\fI\,https://github.com/mayTermux/awesomeshot/wiki\/\fR +.SH "REPORTING BUGS" +Report bugs to +.IP +\fI\,https://github.com/mayTermux/awesomeshot/issues\/\fR +.SH "SHOWCASE" +Upload your custom config or script +.IP +\fI\,https://github.com/mayTermux/awesomeshot/issues/4\/\fR .SH META OPTIONS \fB\-h, \-\-help\fR .IP @@ -26,7 +38,218 @@ Run awesomeshot with manual (this option require filename) \fB\-c, \-\-config\fR .IP Generate default config \fI\,awesomeshot.conf\/\fR -.SH "REPORTING BUGS" -Report bugs to +.SH CONFIG OPTIONS +\fB\/screenshot_result_path\fR .IP -\fI\,https://github.com/mayTermux/awesomeshot/issues\/\fR +Make sure when your phone screenshot the result file image\fR +PATH is same with this variable. Default my phone result file\fR +image PATH on +.IP +"/sdcard/DCIM/Screenshots" +.IP +If not same,\fR +you can edit this variable value\fR +.TP +\fB\/convert_to_png\fR +.IP +This variable serves to set the convert image with file type non PNG, change this value\fR +to blank or whatever for disable function and "yes" for enable function.\fR +Convert to PNG if file not PNG\fR +.TP +\fB\/backup\fR +.IP +This variable serves to function to backup original photo\fR +(screenshot result), change this value to blank or whatever for disable\fR +function and 'yes' for enable function\fR +.TP +\fB\/path_backup\fR +.IP +This variable serves to set the original photo backup PATH\fR +.TP +\fB\/hex_color\fR +.IP +Array Hex Color\fR +.TP +\fB\/convert_titlebar\fR +.IP +This variable serves to convert title bar when editing the image, change this value\fR +to blank or whatever for disable convert and 'yes' for enable function\fR +.TP +\fB\/add_on_img\fR +.IP +This variable serves to set where the title bar place, if 'yes' the title bar add on image,\fR +if blank or whatever the title bar will be added at out of image\fR +.TP +\fB\/width_img & height_img\fR +.IP +This variable serves to set the width and height size of title bar.\fR +.IP +NOTE (Bug Found): +.IP +- Sometimes the title bar result is too big or too small +.IP +width_img=$(magick file_name - format '%w' info:) +.IP +height_img=$(magick file_name - format '%h' info:) +.IP +if (( ${width_img} > ${height_img} )); then +.IP + height_img=${width_img} +.IP +elif (( ${width_img} < ${height_img} )); then +.IP + width_img=${height_img} +.IP +fi\fR +.TP +\fB\/titlebar_color\fR +.IP +This variable serves to set titlebar color, if you want to custom the color, you can +change this value with hex color or use the one in the array list.\fR +.TP +\fB\/convert_rounded\fR +.IP +This variable serves to convert rounded corner, change this value +to blank or whatever for disable convert and 'yes' for enable function +\fR +.TP +\fB\/convert_radius\fR +.IP +This variable serves to set how many rounded corners +\fR +.TP +\fB\/convert_first_border\fR +.IP +This variable serves to convert tiny first border (background image) when editing the image, +change this value to blank or whatever for disable convert and 'yes' for enable function +\fR +.TP +\fB\/first_border_color\fR +.IP +This variable serves to set tiny first border color (background image), change this value +to 'none' for transparent background, if you want to custom the color, you can +change this value with hex color or use the one in the array list. +\fR +.TP +\fB\/first_border_size\fR +.IP +This variable serves to set how many size of the first border +NOTE: make sure this value is small, otherwise it will look weird +\fR +.TP +\fB\/convert_second_border\fR +.IP +This variable serves to convert border (background image) when editing the image, +change this value to blank or whatever for disable convert and 'yes' for enable function +\fR +.TP +\fB\/second_border_color\fR +.IP +This variable serves to set border color (background image), change this value +to 'none' for transparent background, if you want to custom the color, you can +change this value with hex color or use the one in the array list. +\fR +.TP +\fB\/second_border_size\fR +.IP +This variable serves to set how many size of the second border +\fR +.TP +\fB\/convert_shadow\fR +.IP +This variable serves to convert the shadow of image, change this value +to blank or whatever for disable function and 'yes' for enable function. +\fR +.TP +\fB\/shadow_color\fR +.IP +This variable serves to set shadow color, if you want to custom the color, you can +change this value with hex color or use the one in the array list. +\fR +.TP +\fb\/shadow_size\fR +.IP +This variable serves to set shadow size, this variable has four values: +shadow_size='75x30+0+30' +that mean: +.IP +- bottom shadow is x75 +.IP +- right shadow is +30 +.IP +- top shadow is +0 +.IP +- left shadow is +30 +\fR +.TP +\fb\/convert_footer\fR +.IP +This variable serves to convert the footer text, change this value +to blank or whatever for disable function and 'yes' for enable function. +\fR +.TP +\fb\/footer_text\fR +.IP +This variable serves to set text of footer, if you want to use icon +you can search on Nerd Fonts Website (\fI\,https://www.nerdfonts.com/cheat-sheet\fR) +NOTE: if you use icon from Nerd Fonts, make sure 'footer_font' using nerd fonts to! +\fR +.TP +\fb\/footer_position\fR +.IP +This variable serves to set text position of footer, the value contain 8 wind direction: +- NorthWest +.IP +- North +.IP +- West +.IP +- Center +.IP +- East +.IP +- SouthWest +.IP +- South +.IP +- SouthEast +.IP +NOTE: Default value is 'South' +\fR +.TP +\fb\/footer_xy\fR +.IP +This variable serves to set position of 'X' and 'Y' +\fR +.TP +\fb\/footer_font\fR +.IP +This variable serves to set the font used when converting, you can check the list font +available to use for ImageMagick by command: +.IP +magick convert -list font | grep -iE 'font:.*' +\fR +.TP +\fb\/footer_font_size\fR +.IP +This variable serves to set font size +\fR +.TP +\fb\/footer_foreground\fR +.IP +This variable serves to set the text color, if you want to custom the color, you can +change this value with hex color or use the one in the array list. +\fR +.TP +\fb\/footer_background\fR +.IP +This variable serves to set footer background color (background text), change this value +to 'none' for transparent background, if you want to custom the color, you can +change this value with hex color or use the one in the array list. +\fR +.TP +\fb\/open_image\fR +.IP +This variable serves to open the result of image (when editing finished), change this value +to blank or whatever for disable function and 'yes' for enable function. +\fR \ No newline at end of file diff --git a/awesomeshot.conf b/awesomeshot.conf index e2f4a98..bd52d82 100644 --- a/awesomeshot.conf +++ b/awesomeshot.conf @@ -2,8 +2,8 @@ # PATH is same with this variable. Default my phone result file # image PATH on "/sdcard/DCIM/Screenshots". If not same, # you can edit this variable value -#screenshot_result_path="/sdcard/Pictures/ScreenMaster" -screenshot_result_path="/sdcard/DCIM/Screenshots" +screenshot_result_path="/sdcard/Pictures/ScreenMaster" +#screenshot_result_path="/sdcard/DCIM/Screenshots" # This variable serves to set the convert image with file type non PNG, change this value # to blank or whatever for disable function and "yes" for enable function. @@ -60,17 +60,30 @@ convert_rounded="yes" # This variable serves to set how many rounded corners border_radius=10 +# This variable serves to convert tiny first border (background image) when editing the image, +# change this value to blank or whatever for disable convert and "yes" for enable function +convert_first_border="yes" + +# This variable serves to set tiny first border color (background image), change this value +# to "none" for transparent background, if you want to custom the color, you can +# change this value with hex color or use the one in the array list. +first_border_color="${hex_color[0]}" + +# This variable serves to set how many size of the first border +# NOTE: make sure this value is small, otherwise it will look weird +first_border_size=7 + # This variable serves to convert border (background image) when editing the image, # change this value to blank or whatever for disable convert and "yes" for enable function -convert_border="yes" +convert_second_border="yes" # This variable serves to set border color (background image), change this value # to "none" for transparent background, if you want to custom the color, you can # change this value with hex color or use the one in the array list. -border_color="${hex_color[0]}" +second_border_color="${hex_color[0]}" -# This variable serves to set how many size of the border -border_size=50 +# This variable serves to set how many size of the second border +second_border_size=50 # This variable serves to convert the shadow of image, change this value # to blank or whatever for disable function and "yes" for enable function.