3

If you do xwininfo it will give you the window id, however, this requires clicking the mouse over a target window. Is there any way to force the window manager, or at least suggest to the window manager, to use a specific id. Something like

gedit windowid=0x12345678


I have uploaded some files to GitHub (see here or here) demonstrating how I managed to work around this. If you look at them you'll get a better feel for what it is I am attempting to do.

puk
  • 16,318
  • 29
  • 119
  • 199
  • Is actually setting the id important or is it that you wish to find out the id of a specific window without having to click it? – Kristofer Oct 19 '11 at 19:33
  • @Kristofer, probably B is right. What would you do then? It's not easy. – Tomas Oct 19 '11 at 20:45
  • @Kristofer yes I need the window ID such that I can move it via `wmctrl`, but I think the command (ie. `gedit`) returns BEFORE the window manager launches the window. so if you issue the command `gedit ; ps ; wmctrl -l -p` chances are the process ID for gedit will show up in `ps` but not `wmctrl -l -p` – puk Oct 19 '11 at 21:56

1 Answers1

1

No, it is not possible. The Window IDs are given by the X server as XCreateWindow/XCreateSimpleWindow are called, and there is no way to change them, it would be terribly dangerous and wrong to let user choose them. If you are planning to find a window, you can try using the XQueryTree function along with XGetWindowProperty and the WM_CLASS property.

moongoal
  • 2,847
  • 22
  • 23
  • then I suppose I have to use `$!` to get the process IDs and use those against the window IDs, once they load. I just can't believe no one has created this. I figure programmers would like it if every time they logged in their different projects would be loaded into the appropriate workspace. – puk Oct 20 '11 at 07:49
  • You're right, but the problem is that X does not directly support workspaces. Workspaces are implemented as part of a protocol, thus some WM may support them, some other may not. In addition, the protocol is just an interface, so different WMs can handle workspaces in different ways. It's not impossible to create such a tool, but you must first understand how X works. If you want to go deeper in this, learn ICCCM and extended ICCCM. Anyway, there is no certain way of matching a PID with a window ID, because the process that shows a window on a screen may have been run on a different machine! – moongoal Oct 20 '11 at 10:15
  • As a last hint, I can tell you that if the WM you are using supports the extended ICCCM protocol, you can find the PID by reading the _NET_WM_PID property of the window, but if it is not supported by the WM, you will get nothing. – moongoal Oct 20 '11 at 10:18
  • yes you are right, the pid returned by `$!` is different from the pid indicated in `wmctrl -l -p – puk Oct 20 '11 at 18:17