feature request: get map of used window space/map of available space
Closed this issue · 9 comments
theres no other tools that do this (if you know of one plz link me)
would love to be able to get a map of available window rects so i can create windows in
Could you elaborate on this? I'd love to implement something that doesn't exist yet!
I think he means a list of screen areas where there are no windows, i.e. where the root window is visible
@Ferdi265 correct. the most common app for printing win data doesnt even list geometries in tree mode (tree mode lists all windows).
The what-is-covered case seems like it would be possible with a loop around lsw
and wattr
; only problem would be duplicated geometries in some cases.
I don't know yet wether this should be done in shell or in C.
@Ferdi265 thanks Ill have a look
ideally something like (pseudo code)
listvisiblegeometry() => [
{ name: Sublime Text 2.0, handle: 0x12341234, geometry: [0,0,800,600] },
{ name: XMMS, handle: 0x12341234, geometry: [900,0,300,200] }
]
and unusedgemetry() => [[0,0,700,200], [500,700,200,800]]
my end goal is do something like for unusedgeometry() ( if (height>200) mplayer somerockvideofromyoutube.mp4 -rect $x,$y,$h,$w )
to play 4-10 copies of the same music video in sync from youtube :)
it should be a cool effect
The first part is easy to handle:
lsw | while read WID; do
printf '{ name: %s, handle: %s, geometry: [%d,%d,%d,%d] },\n' "$(wname $WID)" $(wattr ixywh $WID)
done
For the second one... you'd have to draw a map of your screen, then calculate
all the possible rectangles that could fit in the screen. This sounds possible
even if a bit tricky.
But shell is definitely not the best way to do it, as it's not efficient at all.
One could write a project that reads geometries from stdin, one per line with the
first one being the root windows, then perform the calculation, and output all
geometry to stdout in the form 'x y w h', so you can use it with wtp directly.
I'll try to give it a shot.
The problem with unusedspace() here is that in some cases, the possible windows are ambiguous. (i.e. there are multiple ways to split the empty space into rectangles)
Best would be to just say "don't rely on the order and/or location/size of the individual rectangles in unusedspace()". Best would probably be to just write some geometry arithmetic library that can compute union, difference and intersection of geometries, for use in tools like wmutils and similar