>>106504637
#!/bin/bash
WATCH_DIR="/home/user/Downloads"
PREFIX="ai_studio_code"
# Requires: inotify-tools, yad, xclip, libnotify-bin
# Install (Debian/Ubuntu): sudo apt install inotify-tools yad xclip libnotify-bin
inotifywait -m -e close_write --format "%f" "$WATCH_DIR" | while read FILE; do
if [[ $FILE == ${PREFIX}* ]]; then
SRC="$WATCH_DIR/$FILE"
# Get clipboard contents
CLIP=$(xclip -o -selection clipboard 2>/dev/null || echo "")
# If clipboard looks like an absolute path (simple regex check)
if [[ $CLIP =~ ^/[^[:space:]]+ ]]; then
DEFAULT_TEXT="$CLIP"
else
DEFAULT_TEXT=""
fi
DEST=$(yad --entry --width=200 \
--title="Save as..." \
--text="Detected: $FILE\nEnter full destination file path:" \
--entry-text="$DEFAULT_TEXT" \
--center --on-top) || continue
[[ -z "$DEST" ]] && continue
mkdir -p "$(dirname "$DEST")"
cp -- "$SRC" "$DEST" && \
notify-send "File saved" "Copied to $DEST" || \
notify-send "Error" "Failed to copy $SRC to $DEST"
fi
done