[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

Re: Modified X Window programming query

> Hi! Thanks for you replies about my X Window programming query, but I think that is not what I am looking for. Let me be clearer.
> I am writing a window monitoring program in C that keeps track of all the windows that are opened (in X Window; Linux). For this I
am using Xlib and *no toolkit*. Using the Xlib functions, I am able to get the *caption* of each open window. Now, I want to find
out (that is, write the code to determine) the program or application that opens each window. For example, for the window with
caption "Media Player", the  program responsible is "kmidi". For the caption "/home/test.c", the program is "kwrite" or may be
"kedit". What should my "monitoring program" do to make this inference?
> Please note that I do not want to manually configure anything.



for something that tries to do something remotely (yes, pun is intended) similar to this.

Given what is available in the X11 API, I think what you're trying to do is hard -
mainly because X protocol doesn't assume anything about the host OS - you could
be running on UNIX, VMS, Windows or a PDA. Also, X assumes that everything could
possibly be remote.

Given all this, here is what you could do:

(a) Somehow get the pid of the process that spawned the window (I think it's hard,
     but might be possible). Then you can grab the command line from /proc or some
     such API.

(b) If you have control over the apps that are running under X, make them set the
     command line as a window property. Then you can get that property (see the
     above example) to get the command line.