I want to use drag'n'drop in a script ,to work without mouse or keyboard intervention.This script should take (drag) some files and folders ,and put (drop) into the chroot environment inside the software Cubic.And after that to auto press the button "Copy" from Cubic.So all must be autonomous and automated. I searched all over here and on other sites/forums ,and found these discussions : https://unix.stackexchange.com/questions/216507/drag-and-drop-without-the-drag/557100#557100
https://unix.stackexchange.com/questions/137905/can-i-drag-a-file-into-a-window-without-a-file-manager
From first link I would like to use this scrip ,but I don't know how to modify it to work for what I want:
#!/usr/bin/env bash
doc="$0 <filename|'shot'>
With filename: Drags given file to where the mouse is using dragon.
Click to drop it (anywere).
With 'shot' : File will be a shot of a an area to be selected.
=> 'drag_into shot' on a hotkey combo makes sense.
"
cmd_shot="shot"
file=
exit_help () { echo -e "$doc"; exit 1; }
select_shot_area () {
# create screen shot
notify-send "Select area - we'll shoot it and drag to where the mouse is."
cd "$HOME/Pictures/shots/" || exit 1
rm -f "latest.png"
scrot -s '%Y-%m-%d_$wx$h_scrot.png' -e 'ln -s $f latest.png'
file="`readlink latest.png`"
}
main () {
file="$1"
test -z "$file" -o "$file" == "-h" && exit_help
eval "$(xdotool getmouselocation --shell)" # into $X and $Y
test "$file" == "$cmd_shot" && { select_shot_area || return 1; }
killall dragon 2>/dev/null # No accidential drops of wrong items ...
dragon --and-exit "$file" &
while true; do
xid="$(xdotool search --onlyvisible --class dragon | head -n 2)"
test -z "$xid" || break
sleep 0.05
done
xdotool mousemove --sync -w "$xid" 1 1 mousedown 1 mousemove $X $Y
notify-send "Click to drop $file..."
}
main "$@"`
So could be modified this script ,or make/create a new and different one?And how?