Closed 4164696f73 closed 1 year ago
Hello. I tried your example and my test didn't work, but because in my case the returned window id was 0. I'm pretty sure it's because I tested it on wayland. I have to test it on X11, but it'll take some time (I have to take care of the PR #10.
In meantime you can test, if the PR #10 doesn't fix your issue.
And if not, you can try to check how this kind of example behaves if written in C with xcb (you can take inspiration from test code I wrote when we tried to debug issue #6). I think, I read somewhere, that the filling of _NET_WM_PID is not mandatory for a X11 program and it may be the case, that the active window has no PID.
_NET_WM_PID is a uint32
@4164696f73 as @aarzilli and specification says, the _NET_WM_PID
is CARDINAL/32
which translates to uint32
in go
language. So the last print of your example should be fmt.Printf("Active window pid: %d\n", uint32(reply.Value))
.
Does this fix your issue? Can we close this?
@4164696f73 No answer, I assume everything is alright. Closing.
I apologize for the delay. I managed to check your suggestions (finally!) and it ended up working with:
fmt.Printf("Active window pid: %d\n", binary.LittleEndian.Uint32(reply.Value))
I couldn't use just uint32(reply.Value)
because you can't convert bytes like that, and binary.LittleEndian.Uint32(reply.Value)
did the trick.
Sorry again for being absent this long.
I've been trying to get the active window PID, but all I am getting is a random string. First it was "]", then "", then "h" - it changes with different windows (basically, different PID = different symbol returned).
I assume I'm missing something, but I can't find anything that would help me to get the PID.
Here's the code (basically what is in examples, but changed "_NET_WM_NAME" to "_NET_WM_PID).