imgs/Upload to imgs

39 lines
1.2 KiB
Plaintext
Raw Normal View History

2022-01-05 08:32:46 +03:00
#!/usr/bin/env bash
# This is an imgs <https://gitea.gch.icu/ge/imgs> "integration" for Nautilus.
# Place this script into path: $HOME/.local/share/nautilus/scripts
# See more info at: <https://help.ubuntu.com/community/NautilusScriptsHowto>
imgs_check_vars() {
[ "$IMGSLOG" ] || IMGSLOG=$HOME/imgs_debug.log
[ "$IMGSREMOTE" ] && return 0 # exit from func if variable is set
if [ -f "$HOME/.imgsremote" ]; then
. $HOME/.imgsremote
fi
if [ "$IMGSREMOTE" ]; then
:
else
echo "$0: Error: IMGSREMOTE variable is not set." >&2
exit 1
fi
}
2022-01-29 02:43:50 +03:00
imgs_check_vars
2022-01-05 08:32:46 +03:00
[ "$IMGSDEBUG" ] && date +"[%d %b %Y %H:%M:%S] Started" >> "$IMGSLOG"
while read -r file; do
[ "$file" ] || break
if [ "$IMGSDEBUG" ]; then
image="$(curl -v -L -F "image=@$file" "$IMGSREMOTE" 2>&1 | tee -a "$IMGSLOG")"
image="$(tail -n 1 <<< "$image")"
else
image="$(curl -L -F "image=@$file" "$IMGSREMOTE")"
fi
[ "$IMGSDEBUG" ] && echo "$(date +"[%d %b %Y %H:%M:%S]") $file --> $image" >> "$IMGSLOG"
notify-send "File uploaded to imgs!" "$image"
done <<< "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS"
[ "$IMGSDEBUG" ] && date +"[%d %b %Y %H:%M:%S] Finished" >> "$IMGSLOG"