36 lines
980 B
Bash
Executable file
36 lines
980 B
Bash
Executable file
#!/bin/bash
|
|
if [ ! -f "$1" ]; then
|
|
kdialog --passivepopup "No File!" 5
|
|
exit
|
|
fi
|
|
|
|
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
|
|
|
|
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
|
|
|
|
if [ -f "$1" ]; 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)
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
if [ "$XDG_SESSION_TYPE" == "x11" ]; then
|
|
echo "$remote_path/$variable.$ext" | xclip -selection clipboard
|
|
else
|
|
wl-copy "$remote_path/$variable.$ext" &> /dev/null
|
|
fi
|
|
|
|
kdialog --passivepopup "Uploaded! $remote_path/$variable.$ext" 5
|
|
ffplay /usr/share/sounds/freedesktop/stereo/service-login.oga -hide_banner -autoexit -nodisp
|