Skip to content

Commit

Permalink
Merge pull request #8 from mayTermux/dev
Browse files Browse the repository at this point in the history
Fix bug screenshot filename '.pending' and change other stuff configuration
  • Loading branch information
nihsx authored Apr 18, 2022
2 parents ee2633f + d27f322 commit 0fc3084
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 26 deletions.
46 changes: 29 additions & 17 deletions awesomeshot
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#
# Copyright (c) 2021 - 2022 xShin

version=1.0.2
version=1.0.5

XDG_CONFIG_HOME=${XDG_CONFIG_HOME:-${HOME}/.config}
config_file="${XDG_CONFIG_HOME}/awesomeshot/awesomeshot.conf"
Expand All @@ -24,17 +24,22 @@ COLOR_SKY="\e[34m"
read -rd '' config <<'EOF'
# 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/Pictures/Screenshots". If not same,
# image PATH on "/sdcard/DCIM/Screenshots". If not same,
# you can edit this variable value
screenshot_result_path="/sdcard/Pictures/Screenshots"
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.
# Convert to PNG if file not PNG
convert_to_png="yes"
# 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
backup="yes"
# This variable serves to set the original photo backup PATH
path_backup="${HOME}/.config/awesomeshot/backup"
path_backup="/sdcard/DCIM/awesomeshot"
# Array Hex Color
hex_color=(
Expand Down Expand Up @@ -66,6 +71,10 @@ add_on_img=""
width_img=500
height_img=1000
# 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.
titlebar_color="${hex_color[0]}"
# This variable serves to convert rounded corner, change this value
# to blank or whatever for disable convert and "yes" for enable function
convert_rounded="yes"
Expand Down Expand Up @@ -143,11 +152,6 @@ footer_foreground="${hex_color[1]}"
# change this value with hex color or use the one in the array list.
footer_background="none"
# 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
convert_to_png="yes"
# 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.
open_image=""
Expand Down Expand Up @@ -175,7 +179,7 @@ function getUserConfig() {
function generateDefaultConfig() {
if [ ! -f "${config_file}" ]; then
if [ ! -d "~/.config/awesomeshot" ]; then
mkdir ~/.config/awesomeshot
mkdir ~/.config/awesomeshot 2> /dev/null
fi
printf '%s\n' "$config" > "$config_file"
stat "SUCCESS" "Success" "Default config has been generated"
Expand Down Expand Up @@ -233,16 +237,22 @@ function autoRun() {
get_file_name=$(echo -e "${get_file_name_result}" | awk '{print $3}')
if [[ "${screenshot_result_path}/${get_file_name}" != "${file_name}" || -z ${file_name} ]]; then
subtitle "[+]*Execute*Program*"
file_name="${screenshot_result_path}/${get_file_name}"

# Fix bug screenshot filename ".pending"
if [ ${get_file_name%%-*} == ".pending" ]; then
file_name="${screenshot_result_path}/${get_file_name##*-}"
else
file_name="${screenshot_result_path}/${get_file_name}"
fi

echo -e ""

if [ "${convert_to_png}" == "yes" ]; then
convertToPng "${get_file_name}"
convertToPng
fi

if [ "${backup}" == "yes" ]; then
title "${COLOR_SKY}[+] BACKUP${COLOR_DEFAULT}"
title "${COLOR_SKY}[+] BACKUP IMAGE${COLOR_DEFAULT}"
backupOriginalPhoto "${get_file_name}"
fi

Expand Down Expand Up @@ -295,7 +305,7 @@ function manualRun() {
fi

if [ "${backup}" == "yes" ]; then
title "${COLOR_SKY}[+] BACKUP${COLOR_DEFAULT}"
title "${COLOR_SKY}[+] BACKUP IMAGE${COLOR_DEFAULT}"
backupOriginalPhoto "${get_file_name}"
fi

Expand All @@ -316,7 +326,7 @@ function manualRun() {
if [ "${convert_border}" == "yes" ]; then
convertBorder
fi

if [ "${convert_footer}" == "yes" ]; then
convertFooter
fi
Expand Down Expand Up @@ -353,6 +363,8 @@ function backupOriginalPhoto() {
check

fi
termux-media-scan -r "${path_backup}" &> /dev/null
termux-media-scan "${path_backup}/${change_filename_backup}" &> /dev/null
}

function convertToPng() {
Expand Down Expand Up @@ -397,7 +409,7 @@ function convertTitleBar(){
#760x360
if [[ "${add_on_img}" == "yes" ]]; then
magick $file_name -fill $b \
-background $b \
-background ${titlebar_color} \
-gravity north \
-chop 0x$br \
-splice 0x$br \
Expand All @@ -407,7 +419,7 @@ function convertTitleBar(){
$file_name
else
magick $file_name -fill $b \
-background $b \
-background ${titlebar_color} \
-gravity north -splice 0x$br\
-draw "fill ${r} circle ${arr[0,0]},${arr[0,1]} ${arr[0,2]},${arr[0,3]}
fill ${y} circle ${arr[1,0]},${arr[1,1]} ${arr[1,2]},${arr[1,3]}
Expand Down
2 changes: 1 addition & 1 deletion awesomeshot.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH AWESOMESHOT 1 "Mar 2022" "Awesomeshot 1.0.2" "User Commands"
.TH AWESOMESHOT 1 "18 April 2022" "Awesomeshot 1.0.5" "User Commands"
.SH NAME
Awesomeshot
.SH SYNOPSIS
Expand Down
20 changes: 12 additions & 8 deletions awesomeshot.conf
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
# 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/Pictures/Screenshots". If not same,
# image PATH on "/sdcard/DCIM/Screenshots". If not same,
# you can edit this variable value
screenshot_result_path="/sdcard/Pictures/Screenshots"
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.
# Convert to PNG if file not PNG
convert_to_png="yes"

# 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
backup="yes"

# This variable serves to set the original photo backup PATH
path_backup="${HOME}/.config/awesomeshot/backup"
path_backup="/sdcard/DCIM/awesomeshot"

# Array Hex Color
hex_color=(
Expand Down Expand Up @@ -42,6 +47,10 @@ add_on_img=""
width_img=500
height_img=1000

# 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.
titlebar_color="${hex_color[0]}"

# This variable serves to convert rounded corner, change this value
# to blank or whatever for disable convert and "yes" for enable function
convert_rounded="yes"
Expand Down Expand Up @@ -119,11 +128,6 @@ footer_foreground="${hex_color[1]}"
# change this value with hex color or use the one in the array list.
footer_background="none"

# 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
convert_to_png="yes"

# 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.
open_image=""

0 comments on commit 0fc3084

Please sign in to comment.