xprop | grep WM_CLASS\(STRING\)
After typing that into a terminal, I have to click onto a window to get a result.
I want to automatize this. I'd like to get the WM_NAME-Window name at a named position, say, x=10 and y=40 (BFB).
xprop | grep WM_NAME\(STRING\)
sleep(1)
xdotool mousemove 10 40 click 1
Each command on its own is working, but not all together. How can I put this into a script that executes all commands?
The problem is that xprop is blocking for the mouse click so it needs to be done in the background. The wait
is not strictly necessary, but makes the script exit more cleanly by waiting for xprop
to complete.
#!/bin/bash
xprop | grep WM_NAME\(STRING\) &
pid=!$
sleep 1
xdotool mousemove 10 40 click 1
wait $pid