add upload sound

This commit is contained in:
zyqunix 2025-04-28 23:16:05 +02:00
parent 8378f5b1d6
commit c037ddc0cd
No known key found for this signature in database
GPG key ID: 134A8DEEA83B80E6
3 changed files with 29 additions and 3 deletions

View file

@ -200,6 +200,7 @@ setup_config() {
local show_notifications local show_notifications
local save_images local save_images
local default_option local default_option
local snip_sound
echo -ne "${CYAN}What do you want the default option to be? (upload/save/copy): ${RESET}" echo -ne "${CYAN}What do you want the default option to be? (upload/save/copy): ${RESET}"
read default_option read default_option
@ -244,6 +245,16 @@ setup_config() {
[[ "$show_notifications" =~ ^(y|Y)$ ]] && show_notifications="true" || show_notifications="false" [[ "$show_notifications" =~ ^(y|Y)$ ]] && show_notifications="true" || show_notifications="false"
set_value "SHOW_NOTIFICATIONS" "$show_notifications" set_value "SHOW_NOTIFICATIONS" "$show_notifications"
echo -ne "${CYAN}Do you want to play a sound after upload? (y/n): ${RESET}"
read snip_sound
while ! [[ "$snip_sound" =~ ^(y|Y|n|N|true|false)$ ]]; do
echo -e "${RED}Invalid option. Please enter 'y' or 'n'.${RESET}"
echo -ne "${CYAN}Do you want to play a sound after upload? (y/n): ${RESET}"
read snip_sound
done
[[ "$snip_sound" =~ ^(y|Y)$ ]] && snip_sound="true" || snip_sound="false"
set_value "SNIP_SOUND" "$snip_sound"
echo -ne "${CYAN}Do you want to show capture preview? (y/n): ${RESET}" echo -ne "${CYAN}Do you want to show capture preview? (y/n): ${RESET}"
read show_capture_preview read show_capture_preview
while ! [[ "$show_capture_preview" =~ ^(y|Y|n|N|true|false)$ ]]; do while ! [[ "$show_capture_preview" =~ ^(y|Y|n|N|true|false)$ ]]; do
@ -258,4 +269,4 @@ setup_config() {
echo -e "${YELLOW}You can change the configuration later by running the script with the --config option.${RESET}" echo -e "${YELLOW}You can change the configuration later by running the script with the --config option.${RESET}"
[[ "$show_capture_preview" == "true" ]] && setup_venv [[ "$show_capture_preview" == "true" ]] && setup_venv
} }

View file

@ -13,6 +13,7 @@ declare -A ALLOWED_KEYS=(
["log_level"]="^(DEBUG|INFO|WARN|ERROR)$" ["log_level"]="^(DEBUG|INFO|WARN|ERROR)$"
["SHOW_CAPTURE_PREVIEW"]="^(true|false)$" ["SHOW_CAPTURE_PREVIEW"]="^(true|false)$"
["SHOW_NOTIFICATIONS"]="^(true|false)$" ["SHOW_NOTIFICATIONS"]="^(true|false)$"
["SNIP_SOUND"]="^(true|false)$"
["SAVE_IMAGES"]="^(true|false)$" ["SAVE_IMAGES"]="^(true|false)$"
["SAVE_DIR"]="^.+$" ["SAVE_DIR"]="^.+$"
["DOMAIN"]="^.+$" ["DOMAIN"]="^.+$"
@ -29,6 +30,7 @@ declare -A ALLOWED_KEYS=(
REQUIRED_KEYS=( REQUIRED_KEYS=(
"SHOW_CAPTURE_PREVIEW" "SHOW_CAPTURE_PREVIEW"
"SHOW_NOTIFICATIONS" "SHOW_NOTIFICATIONS"
"SNIP_SOUND"
"SAVE_IMAGES" "SAVE_IMAGES"
"DEFAULT_OPTION" "DEFAULT_OPTION"
) )
@ -65,4 +67,4 @@ declare -A UPLOAD_JSON_KEYS=(
["ez"]="imageUrl" ["ez"]="imageUrl"
["fakecrime"]="url" ["fakecrime"]="url"
["zipline"]="files[0].url" ["zipline"]="files[0].url"
) )

15
main.sh
View file

@ -65,6 +65,7 @@ while [[ $# -gt 0 ]]; do
--silent) --silent)
SHOW_NOTIFICATIONS=false SHOW_NOTIFICATIONS=false
SHOW_CAPTURE_PREVIEW=false SHOW_CAPTURE_PREVIEW=false
SNIP_SOUND=false
shift shift
;; ;;
--*) --*)
@ -93,6 +94,9 @@ SHOULD_UPLOAD=$(get_value "DEFAULT_OPTION")
SHOW_NOTIFICATIONS=$(get_value "SHOW_NOTIFICATIONS") SHOW_NOTIFICATIONS=$(get_value "SHOW_NOTIFICATIONS")
[[ "$SHOW_NOTIFICATIONS" == "true" ]] && SHOW_NOTIFICATIONS=true || SHOW_NOTIFICATIONS=false [[ "$SHOW_NOTIFICATIONS" == "true" ]] && SHOW_NOTIFICATIONS=true || SHOW_NOTIFICATIONS=false
SNIP_SOUND=$(get_value "SNIP_SOUND")
[[ "$SNIP_SOUND" == "true" ]] && SNIP_SOUND=true || SNIP_SOUND=false
SHOW_CAPTURE_PREVIEW=$(get_value "SHOW_CAPTURE_PREVIEW") SHOW_CAPTURE_PREVIEW=$(get_value "SHOW_CAPTURE_PREVIEW")
[[ "$SHOW_CAPTURE_PREVIEW" == "true" ]] && SHOW_CAPTURE_PREVIEW=true || SHOW_CAPTURE_PREVIEW=false [[ "$SHOW_CAPTURE_PREVIEW" == "true" ]] && SHOW_CAPTURE_PREVIEW=true || SHOW_CAPTURE_PREVIEW=false
@ -151,6 +155,12 @@ send_notification() {
"${notify_cmd[@]}" "${notify_cmd[@]}"
} }
play_sound() {
[[ "$SNIP_SOUND" == "false" ]] && return
paplay /usr/share/sounds/freedesktop/stereo/camera-shutter.oga
}
SHOULD_UPLOAD=false SHOULD_UPLOAD=false
SHOULD_SAVE="$(get_value "SAVE_IMAGES")" SHOULD_SAVE="$(get_value "SAVE_IMAGES")"
SHOULD_COPY=false SHOULD_COPY=false
@ -365,18 +375,21 @@ MIME_TYPE=$(file --mime-type -b "$FILE")
if [[ "$MIME_TYPE" == image/* ]]; then if [[ "$MIME_TYPE" == image/* ]]; then
if [[ "$SHOW_NOTIFICATIONS" == "true" ]]; then if [[ "$SHOW_NOTIFICATIONS" == "true" ]]; then
send_notification "Uploaded to $SERVICE" "$FILE_URL" "$FILE" send_notification "Uploaded to $SERVICE" "$FILE_URL" "$FILE"
play_sound
fi fi
if [[ "$SHOW_CAPTURE_PREVIEW" == "true" ]]; then if [[ "$SHOW_CAPTURE_PREVIEW" == "true" ]]; then
"$PYTHON_EXEC" "$SCRIPT_DIR/helpers/show_image.py" "$FILE" "Uploaded to $SERVICE" "$PYTHON_EXEC" "$SCRIPT_DIR/helpers/show_image.py" "$FILE" "Uploaded to $SERVICE"
play_sound
fi fi
else else
if [[ "$SHOW_NOTIFICATIONS" == "true" ]]; then if [[ "$SHOW_NOTIFICATIONS" == "true" ]]; then
send_notification "Uploaded to $SERVICE" "$FILE_URL" send_notification "Uploaded to $SERVICE" "$FILE_URL"
play_sound
fi fi
fi fi
# delete if should not save and not a user file # delete if should not save and not a user file
if [[ "$SHOULD_SAVE" != "true" && "$USER_FILE" == "" ]]; then if [[ "$SHOULD_SAVE" != "true" && "$USER_FILE" == "" ]]; then
rm -f "$FILE" rm -f "$FILE"
fi fi