Reputation: 830
goal: is to collect information about user interactive program in Tracking app.
most efficient way is through process ID
. the only way i can think of is getting Xlib
Window
associated process ID
, does other ways around?
going through documentation, and source code, no clue for Window associated process ID
attribute, maybe Xlib
doesn't keep PID
, or does it?
non efficient solution is through Window
name attribute.
Upvotes: 0
Views: 408
Reputation: 4170
Xlib doesn't keep process ids - it was designed to work on a variety of OS'es with different process abstractions, and across networks, where a pid on one machine isn't very useful on another machine.
But since most X applications today are being run on Unix-like machines and displayed locally, not over the network, many modern toolkits adopted a convention of storing the process id in a property on the window of that application. See the _NET_WM_PID section of the Extended Window Manager Hints specification for details.
Upvotes: 1
Reputation:
The X server doesn't have that information. In fact, there may not even be a PID available -- clients can connect to an X server over the network.
If all you need to do is identify what program is being used, though, you could look at the WM_CLASS window property. This property contains a pair of strings that are used to identify the window to the window manager, and usually includes the name of the application.
Upvotes: 1