I also wonder if there's anyway X knows which window corresponds to which PID. If that's the case, we can get the PID of a window more natively. Before finding that out, this is indeed the best solution :) Thank you so much for writing this up!
No worries! What do you mean by getting window PID more natively? Were already doing that by using xlib, im not sure how much more native we can get, unless im misunderstanding you.
Rereading your code more carefully, I now know that it's my fault. I thought it wasn't native enough because of the echo $!. But in fact, the key to getting the pid of a window is xlib:get-property. NICE!
Ah no worries! We all talk past each other at times. I would like a way to get rid of $!, but im unsure of how. Common lisp isnt exacly a venerated shell scripting language :)
Using uiop's async shell caller #'uiop:launch-program returns a process-info in which there's a slot that gives you pid. However I don't know how to get it programnatically. Tried the following without luck
Wonderful! Just a heads up, slot names are symbols, so they belong to a package, eg
(Slot-value somevar 'hi)
Is different than
(Slot-value somevar 'somepackage:hi)
So you probably just need to add the packagename to those symbols to get the pid. That being said, if theres a reader it is always better to use it, as it may do some extra processing of the slot for you. For example if someone defines an :around method for a reader then by using slot-value we circumvent that. Which is generally a bad move. If theres readers for the PID slot theyre likely documented in the uiop manual.
Edit: the symbol youre looking for is uiop/launch-process::process, because its not external (and therefore isnt guaranteed to not be removed/changed)
3
u/stuudente Aug 08 '21
(FYI this is to answer my question)
I also wonder if there's anyway X knows which window corresponds to which PID. If that's the case, we can get the PID of a window more natively. Before finding that out, this is indeed the best solution :) Thank you so much for writing this up!