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