64 lines
1.4 KiB
Bash
Executable File
64 lines
1.4 KiB
Bash
Executable File
#!/bin/bash
|
|
# Dependencies: curl, notify-send, xclip
|
|
|
|
url='https://jirafeau.tld.com'
|
|
time='month'
|
|
upload_password=''
|
|
apipage='script.php'
|
|
downloadpage='f.php'
|
|
curl="/usr/bin/curl"
|
|
|
|
function _notify()
|
|
{
|
|
notify-send --expire-time 2000 \
|
|
--app-name 'my-uploader' \
|
|
--icon 'flameshot' \
|
|
"$1" "$2"
|
|
}
|
|
|
|
if [ ! -f "$1" ]
|
|
then
|
|
_notify 'My uploader' 'Error: Invalid screenshot file.'
|
|
exit 1
|
|
fi
|
|
|
|
#_notify 'My uploader' 'Uploading screenshot to jirafeau ...'
|
|
|
|
res=$($curl --silent -XPOST \
|
|
-F "time=$time" \
|
|
-F "file=@$1" \
|
|
$url$apipage)
|
|
|
|
if [[ "$res" == Error* ]]; then
|
|
_notify 'Error while uploading.'
|
|
exit
|
|
fi
|
|
|
|
|
|
code=$(cnt=0; echo "$res" | while read l; do
|
|
if [[ "$cnt" == "0" ]]; then
|
|
echo "$l"
|
|
fi
|
|
cnt=$(( cnt + 1 ))
|
|
done)
|
|
del_code=$(cnt=0; echo "$res" | while read l; do
|
|
if [[ "$cnt" == "1" ]]; then
|
|
_notify 'Error'
|
|
fi
|
|
cnt=$(( cnt + 1 ))
|
|
done)
|
|
key_code=$(cnt=0; echo "$res" | while read l; do
|
|
if [[ "$cnt" == "2" ]]; then
|
|
_notify 'Error'
|
|
fi
|
|
cnt=$(( cnt + 1 ))
|
|
done)
|
|
|
|
|
|
if [[ $key_code ]]; then
|
|
echo -n "${url}${downloadpage}?h=$code&k=$key_code" | xclip -selection clipboard
|
|
else
|
|
echo -n "${url}${downloadpage}?h=$code" | xclip -selection clipboard
|
|
fi
|
|
_notify 'My uploader' 'Success! The link was sent to your clipboard'
|