1

The question refers to: Linux Ubuntu, with Cinnamon desktop

Several program windows can be displayed on a desktop.

How can I get the WID via bash which window the mouse pointer is over?

Alfred.37
  • 181
  • 1
  • 12
  • Does this answer your question? [Is there a linux command to determine the window IDs associated with a given process ID?](https://stackoverflow.com/questions/2250757/is-there-a-linux-command-to-determine-the-window-ids-associated-with-a-given-pro) – tdy Sep 18 '21 at 08:26
  • @tdy, My question is not releated to this. – Alfred.37 Sep 18 '21 at 08:31
  • 2
    What information do you want about the window, and what will you do with it? – tgdavies Sep 18 '21 at 08:46
  • @tgdavies, The WID of the window will be great. – Alfred.37 Sep 18 '21 at 09:09
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Sep 25 '21 at 05:01
  • @Community, Done. – Alfred.37 Sep 25 '21 at 06:15

1 Answers1

3

I cannot test this at the moment, but maybe xdotool offers a way to get the window under the mouse cursor. From man xdotool:

getmouselocation [--shell]
Outputs the x, y, screen, and window id of the mouse cursor.

I assume the mentioned window id belongs to the window under the mouse cursor. To retrieve it, use

declare "$(xdotool getmouselocation --shell | grep WINDOW)"
echo "$WINDOW"

The window id can then be used in other tools like xwininfo -id <wdid> to get more information.

Alfred.37
  • 181
  • 1
  • 12
Socowi
  • 25,550
  • 3
  • 32
  • 54