Liupold/pidswallow

xprop -spy doesn't detect window changes

SeerLite opened this issue · 23 comments

xprop -spy only outputs lines when windows are focused. I'm not sure if this is intended.
I hadn't noticed this before because I have a special keybind that does something every once in a while that also triggers xprop -spy.

This is a problem in bspwm, for example, where moving the window around won't update the position and resizing won't update the size.

Edit: to reproduce, have a floating terminal and move it around with super + mouse (assuming that config hasn't been changed). Launching anything from that terminal will use the old position and not the new one.

Edit: I just realized it's kind of program-dependant. For instance, I'm testing Alacritty.

No this is not intended and i know about this. I am not aware of any solution, Feel free to fix / change xprop -spy

Yup that's the problem right now. I don't know any tool that can "subscribe" to window events independently of the WM in use. Maybe adding a new WM-specific variable (this is getting ridiculous though) for subscribing to window events (bspc subscribe/i3-msg -t subscribe)?

Yup that's the problem right now. I don't know any tool that can "subscribe" to window events independently of the WM in use. Maybe adding a new WM-specific variable (this is getting ridiculous though) for subscribing to window events (bspc subscribe/i3-msg -t subscribe)?

Nope! no more wm specific variable. (I will have nightmares).

Alright :S but something has to be done though. I'll test xprop -spy a bit more before looking for something new

xev -1 -root -geometry 0x0 maybe ? 0_O (but it is stupid)

Here you go:
xev -id <WID> -1 -geometry 0x0 -event structure

Here you go:
xev -id <WID> -1 -geometry 0x0 -event structure

We can extract the size and pos from this.

Wow you are really fast!
How did you even discover this?

by playing around with xorg. (I like to play around with stuff)

Check out this nasty sed regex I came up with:

xev -id "$(bspc query -N -n)" -1 -geometry 0x0 -event structure | sed -e 's/.*(\(-\?[0-9]\+\),\(-\?[0-9]\+\)),/\1 \2/' -e 's/width \([0-9]\+\), height \([0-9]\+\).*/\1 \2/'

I can't believe I did all that thinking only BRE was POSIX and now reading this I realize ERE is also POSIX.

Yeah.. I'm making that more readable

Edit: ERE variant:

xev -id "$(bspc query -N -n)" -1 -geometry 0x0 -event structure | sed -E -e 's/.*\((-?[0-9]+),(-?[0-9]+)\),/\1 \2/' -e 's/width ([0-9]+), height ([0-9]+).*/\1 \2/'
xev -id "$(bspc query -N -n)" -1 -geometry 0x0 -event structure | sed -E -e 's/.*\((-?[0-9]+),(-?[0-9]+)\),/\1 \2/' -e 's/width ([0-9]+), height ([0-9]+).*/\1 \2/'

we don't need -geometry 0x0,

It's great now we can put everything in one file.

Ok, this is gonna sound really dumb now, but I've been fighting with read for the last minutes (trying to do read -r x y width height) but the thing just won't work. I'm losing my mind rn

I'm using mrsh and dash (both POSIX) to test, and none of them give any output with

xev -id "$(bspc query -N -n)" -1 -event structure | sed -E -e 's/.*\((-?[0-9]+),(-?[0-9]+)\),/\1 \2/' -e 's/width ([0-9]+), height ([0-9]+).*/\1 \2/' | while read -r x y width height; do echo $x $y $width $height; done

read the event and then use sed.

<xev....> | while read -r event

Yeah that sounds like a solution. Feels a bit slower though, doesn't it? The whole point of read is to "split" the input into the variables.

you might want to push that branch to github. so i can look into it

read the event and then use sed.

Wait but how do I set them up for each variable after that

read the event and then use sed.

Wait but how do I set them up for each variable after that

well it's a bit confusing, let me know after you push,

xev-subscribe branch is what I got going on so far

65cfa81 fixed it., you need some sleep i guess.

I had no idea about -u. You're amazing

fixed on #35