I can get X and Y of the active window with xdotool getwindowgeometry --shell $(xdotool getactivewindow)
. How do I do a backwards process - find window id given its X and Y? I'm only interested in the topmost window, not the one that may be hidden underneath the one on top.
1 Answer
I've figured it out myself:
xdotool mousemove 500 100 getmouselocation --shell mousemove restore
This briefly moves the mouse to the specified position (x=500, y=100 in this example), prints WINDOW
which is the windowid
on top, then moves the mouse back.
This is probably not the intended usage of mousemove, but I could not find any better way to do what I wanted.
getactivewindow