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