Bspwm: Resize With Single Combo

Created on 27 Jul 2018  路  9Comments  路  Source: baskerville/bspwm

Hey, was wondering if there is some way to resize windows with a single combo, rather than two separate ones for grow and expand.

Instead of making the key going "back" when growing dead, it would instead subtract. Is this possible?

All 9 comments

Suppose that you have the following triple window setup on your workspace:

|               |                   |                  |
|               |                   |                  |
|               |                   |                  |
|               |                   |                  |
|               |                   |                  |
|               |         X         |                  |
|               |                   |                  |
|               |                   |                  |
|               |                   |                  |
|               |                   |                  |
|               |                   |                  |
|               |                   |                  |
+------------------------------------------------------+

If you currently have the middle window (marked X) selected and you enter a command "left". How do you distinguish between growing the left edge of the window outwards to increase the size vs shrinking the right edge in to decrease the size? It is indeterminate which outcome you want if you are only using a single hotkey.

The only way to achieve what you have stated is to do it how i3 does it i.e. always treat resizing as moving the bottom right corner around.

I feel like there are a couple improvements to even using one of the corners to resize a window. For example, if a window is up against a border of a screen, and you resize towards/away from that border, a corner should be chosen that is opposite that border, to resize with.

This way, windows along the edges of the screen can be resized intuitively without extra key shenanigans

How about the following idea to overcome the ambiguity mentioned here:

If you currently have the middle window (marked X) selected and you enter a command "left". How do you distinguish between growing the left edge of the window outwards to increase the size vs shrinking the right edge in to decrease the size? It is indeterminate which outcome you want if you are only using a single hotkey.

I think we can solve this problem by using the fact that this is a binary space partioning wm. Let's say all nodes split vertically. Then we could move the border between the focused node and its brother (i.e. adjust the splitting ratio of the parent).
If the split directions are mixed, for example like this

|   | x |
|   +---|
|   |   |
+-------+

and we want to resize horizontally we could adjust the splitting ratio of the parent of the parent.

In general we could always adjust the splitting ratio of the "first" parent whose splitType matches the one we want.

I created a pull request #1069 that could help solving this issue.
As you can read over there i created modifiers to check the split type and a descriptor that let's you select the closest descendant (or "first" parent if you wish).

With a line like this in your sxhkdrc

super + alt + {h,j,k,l}
    bspc node 'parents.!leaf.{vertical' -r -,horizontal' -r +,horizontal' -r -,vertical' -r +}0.05

you can now do what i described earlier here @https://github.com/baskerville/bspwm/issues/823#issuecomment-591631352
I hope it is clear what i'm trying to achieve with this. If not please let me know.

Please note that the names of the descriptor and modifier might be different from those used here. Also the ".!leaf" might become redundant. So better check at #1069 first before blindly coying the command.

I noticed that this (https://github.com/baskerville/bspwm/issues/823#issuecomment-592552528) doesn't work with floating windows. I wrote a script to define a different behaviour in case the window is floating. You might want to check it out here.
It is not really elegant but i think as of now there isn't really a better way to do it.

If you have wmutils, you might also enjoy the solution by @turquoise-hexagon : https://github.com/turquoise-hexagon/dots/blob/master/wm/.local/bin/resize

Thanks. I guess your getting that from one of the answers on my reddit post 馃槃? For anybody else: His (or her) solution is pretty simple and doesn't need any modifications. It just resize in the opposite direction if the first try fails.
It's probably much closer to the initial question or might even solve it. Am i seeing that right, @ibrokemypie?

I guess your getting that from one of the answers on...

oh nice lol! No, I had just coordinated with her before on some resize keybinds in and in our quest to find the ultimate focus binding (which I gave up on for now, and they settled on 'good enough') my {focus,resize,move,presel}.sh scripts are all here: https://github.com/neeasade/dotfiles/tree/master/wm/.wm/scripts/interact

Judging by the length of these scripts it seems like you put a bit of thougth into these (i'll go throught them later). I actually didn't expect to a find a solution that would be even 'good enough', so thanks for sharing 馃槂.
Maybe we'll have to come back later to find the 'ultimate' solution, but it looks like someone would again have to put a bit of thought into it.
In case i'll ever bother myself with this again, i'll first make sure to have a solution that fits the current 'interface/style' of bspwm/bspc, before opening another pull request.
I think for now we have enough solutions that work 'good enough' and most people will be happy with.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Anachron picture Anachron  路  3Comments

alecive picture alecive  路  7Comments

icf20 picture icf20  路  5Comments

evanescente-ondine picture evanescente-ondine  路  6Comments

baskerville picture baskerville  路  3Comments