diff --git a/flameshot_example.sh b/flameshot_example.sh index d87e3a0..e40981e 100644 --- a/flameshot_example.sh +++ b/flameshot_example.sh @@ -5,16 +5,23 @@ KEY="" # Your ass upload token DOMAIN="" # Your upload domain (without http:// or https://) flameshot config -f "$IMAGENAME" # Make sure that Flameshot names the file correctly -flameshot gui -r -p "$IMAGEPATH" # Prompt the screenshot GUI +flameshot gui -r -p "$IMAGEPATH" > /dev/null # Prompt the screenshot GUI, also append the random gibberish to /dev/null -# Upload the image and copy the response URL -URL=$(curl -X POST \ - -H "Content-Type: multipart/form-data" \ - -H "Accept: application/json" \ - -H "User-Agent: ShareX/13.4.0" \ - -H "Authorization: $KEY" \ - -F "file=@$IMAGEPATH$IMAGENAME.png" "https://$DOMAIN/" | grep -Po '(?<="resource":")[^"]+') -# printf instead of echo as echo appends a newline -printf "%s" "$URL" | xclip -sel clip +FILE="$IMAGEPATH$IMAGENAME.png" # File path and file name combined -rm "$IMAGEPATH$IMAGENAME.png" # Delete the image locally +# Check if file exists to handle Curl and rm errors +# then upload the image and copy the response URL +if [ -f "$FILE" ]; then + echo "$FILE exists." + URL=$(curl -X POST \ + -H "Content-Type: multipart/form-data" \ + -H "Accept: application/json" \ + -H "User-Agent: ShareX/13.4.0" \ + -H "Authorization: $KEY" \ + -F "file=@$IMAGEPATH$IMAGENAME.png" "https://$DOMAIN/" | grep -Po '(?<="resource":")[^"]+') + # printf instead of echo as echo appends a newline + printf "%s" "$URL" | xclip -sel clip + rm "$IMAGEPATH$IMAGENAME.png" # Delete the image locally +else + echo "Aborted." +fi