commit 5962eee084cfa64685f28916ddfdfad5ff9ec0fb Author: Gabriel Date: Tue Mar 29 12:02:37 2022 +0200 first commit diff --git a/README.md b/README.md new file mode 100644 index 0000000..48a9ffe --- /dev/null +++ b/README.md @@ -0,0 +1,14 @@ +# My uploader + +Uploade des screenshots sur Jirafeau depuis Flameshot : + +https://flameshot.org/ + +Dépendances : ```curl``` ```notify-send``` ```xclip``` + +- Placer *uploader.desktop* dans *~/.local/share/applications/my-uploader.desktop* +- Editer *my-uploader* en fonction des besoins et le placer dans *~/.local/bin/my-uploader* + +**Usage** : Faire une capture avec Flameshot -> *Sélectionner une application pour ouvrir la catpure -> *Jirafeau screenshot uploader* + +L'URL de partage sera dans le presse-papier diff --git a/my-uploader b/my-uploader new file mode 100755 index 0000000..7139755 --- /dev/null +++ b/my-uploader @@ -0,0 +1,63 @@ +#!/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' diff --git a/uploader.desktop b/uploader.desktop new file mode 100644 index 0000000..6fad35a --- /dev/null +++ b/uploader.desktop @@ -0,0 +1,8 @@ +[Desktop Entry] +Type=Application +Name=jirafeau screenshot uploader +Categories=Graphics +Comment=Uploads screenshots to jirafeau using curl +Icon=cloud-upload +Exec=my-uploader %u +Terminal=false