I want to read the content of a text file, copy it to the clipboard (if it is not empty) and then paste to the gedit
window where the mouse cursor is positioned.
Here is my script:
while true
do
if [ -s textfile ]
then
cat textfile | xclip -selection clipboard
xdotool key --clearmodifiers Control_L+v
truncate -s 0 textfile
fi
done
All works except xdotool
:
I have tried some other commands, like:
xdotool key ctrl+v
xdotool type $(xclip -selection clipboard -o)
xdotool getactivewindow type $(xclip -selection clipboard -o)
, that gives me the error XGetWindowProperty[_NET_ACTIVE_WINDOW] failed (code=1)
sleep 1 && xdotool key Control_L+v
No Luck.
Can someone help me?
I solved, the problem was that Libx11-dev was missing. Once the library was installed, the script worked correctly.