4

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.

  • Do you want the id of the active window or of the one at a particular position irrespective of whether it is active? – terdon Jan 18 '15 at 18:08
  • @terdon, second - otherwise I'd just use getactivewindow – Fluffy Jan 19 '15 at 8:46
6

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.