diff --git a/plasma_upload.sh b/plasma_upload.sh index 7334e24..c8ff539 100755 --- a/plasma_upload.sh +++ b/plasma_upload.sh @@ -1,36 +1,44 @@ -#!/bin/bash -if [ ! -f "$1" ]; then - kdialog --passivepopup "No File!" 5 - exit -fi - +#!/bin/sh base=${1%.*} baseName=$(basename "$1") ext=${baseName##*.} variable=$(openssl rand -hex 8) -remote_path=/var/www/html/images #this is the path the file will be uploaded to +REMOTE_NAME=remote +REMOTE_PATH=/var/www/html/images #this is the path the file will be uploaded to +REMOTE_URL=https://example.org/images #no / at end +MAX_COLLISSIONS=5 + +if [ ! -f "$1" ]; then + kdialog --passivepopup "No File!" 5 + exit +fi i=1 while [ -f "$1" ] do -rclone moveto "$1" remote:"$remote_path/$variable.$ext" -v --ignore-existing # ignore existing in case the file already exists +rclone moveto "$1" "$REMOTE_NAME":"$REMOTE_PATH/$variable.$ext" -v --ignore-existing # ignore existing in case the file already exists - if [ -f "$1" ]; then # if the file is still in /tmp we must've gotten some kind of error, we assume its a Collision + if [ -e "$1" ] && [ "$i" -lt $MAX_COLLISSIONS ]; then # if the file is still in /tmp we must've gotten some kind of error, we assume its a Collision kdialog --sorry "Collision $i" i=$((i+1)) variable=$(openssl rand -hex 8) + elif [ "$i" -gt $((MAX_COLLISSIONS-1)) ]; then + kdialog --error "Too many collisions, file still exists at $1. Attempts: $i" + exit fi + done if [ "$XDG_SESSION_TYPE" == "x11" ]; then - echo "$remote_path/$variable.$ext" | xclip -selection clipboard + echo "$REMOTE_URL/$variable.$ext" | xclip -selection clipboard else - wl-copy "$remote_path/$variable.$ext" &> /dev/null + wl-copy "$REMOTE_URL/$variable.$ext" &> /dev/null fi -kdialog --passivepopup "Uploaded! $remote_path/$variable.$ext" 5 +kdialog --passivepopup "Uploaded! $REMOTE_URL/$variable.$ext" 5 ffplay /usr/share/sounds/freedesktop/stereo/service-login.oga -hide_banner -autoexit -nodisp + diff --git a/spectacle.sh b/spectacle.sh new file mode 100755 index 0000000..1c5fe3e --- /dev/null +++ b/spectacle.sh @@ -0,0 +1,17 @@ +#!/bin/sh +TEMP_IMAGE_PATH="/tmp/ion.png" +script_dir="$(dirname "$(realpath "$0")")" #DONOTMODIFY +UPLOAD_SCRIPT_PATH="${script_dir}/plasma_upload.sh" #Only modify if you changed the upload script name or path + +spectacle -rbn -o $TEMP_IMAGE_PATH +if [ -f /tmp/ion.png ]; then + cjpegli -d 0 --chroma_subsampling=444 $TEMP_IMAGE_PATH $TEMP_IMAGE_PATH.jpeg + #oxipng -s -o max $TEMP_IMAGE_PATH + #cjpeg -optimize -progressive -quality 100 $TEMP_IMAGE_PATH > $TEMP_IMAGE_PATH.jpeg + rm $TEMP_IMAGE_PATH -v + + "${UPLOAD_SCRIPT_PATH}" $TEMP_IMAGE_PATH.jpeg #change this to $TEMP_IMAGE_PATH without jpeg at the end when using oxipng!!!! + exit +fi +kdialog --passivepopup "Cancelled!" 5 +ffplay /usr/share/sounds/ocean/stereo/completion-partial.oga -hide_banner -autoexit -nodisp