You are not logged in.

#1 2022-09-15 13:38:13

zacariaz
Member
From: Denmark
Registered: 2012-01-18
Posts: 539

Window management/tiling in openbox - Might be useful to some

I have one of them super ultra wide monitors, and I've been trying to wrap my head around, how to actually organise my windows, as I'd like. The solution I've ended up with, is far from perfect, for me, but I think it is somewhat innovative, or at least different, so I thought I'd share it.
Basically, by using the openbox build-in keybinding feature, in a way I did not at all intent, but was the only way I could get to work, and wmctrl, I can now arrange my windows any way I see fit, with the use of the super key and four taps on the keypad, and the approach is certainly expandable.
For now, by 4 strokes of the keypad, I can have a window in 1 of 30 positions/configurations, or 8 by 8 configuration in terms of position and dimensions, not all being usable, and thus possible.
Basically what you do, is divide your screen in to sectors, horizontally and vertically, and then define the position and dimensions of a given window, by use of the keypad.
Example: Super 1 2 0 1 (use sector 1 and 2 horizontally and 0 and 1 vertically)
Will result in a 2560x1440 window in the middle of my screen, while
Example: Super 0 3 0 1
will effectively be full screen.
I suppose, if you only want to use 2 by 2 sectors, then it won't be all that complicated, with only 9 possible/useful configurations, but in my case, well, it did take some time.

  <keybind key="Super_L">
<!-- other stuff -->
<!-- window management start ->
    <keybind key="KP_0">
      <keybind key="KP_0">
        <keybind key="KP_0">
          <keybind key="KP_0">
            <action name="Execute">
              <command>wmctrl -r :ACTIVE: -e 0,0,0,1280,720</command>
            </action>
          </keybind>
          <keybind key="KP_1">
            <action name="Execute">
              <command>wmctrl -r :ACTIVE: -e 0,0,0,1280,1440</command>
            </action>
          </keybind>
        </keybind>
        <keybind key="KP_1">
          <keybind key="KP_1">
            <action name="Execute">
              <command>wmctrl -r :ACTIVE: -e 0,0,720,1280,720</command>
            </action>
          </keybind>
        </keybind>
      </keybind>
      <keybind key="KP_1">
        <keybind key="KP_0">
          <keybind key="KP_0">
            <action name="Execute">
              <command>wmctrl -r :ACTIVE: -e 0,0,0,2560,720</command>
            </action>
          </keybind>
          <keybind key="KP_1">
            <action name="Execute">
              <command>wmctrl -r :ACTIVE: -e 0,0,0,2560,1440</command>
            </action>
          </keybind>
        </keybind>
        <keybind key="KP_1">
          <keybind key="KP_1">
            <action name="Execute">
              <command>wmctrl -r :ACTIVE: -e 0,0,720,2560,720</command>
            </action>
          </keybind>
        </keybind>
      </keybind>
      <keybind key="KP_2">
        <keybind key="KP_0">
          <keybind key="KP_0">
            <action name="Execute">
              <command>wmctrl -r :ACTIVE: -e 0,0,0,3840,720</command>
            </action>
          </keybind>
          <keybind key="KP_1">
            <action name="Execute">
              <command>wmctrl -r :ACTIVE: -e 0,0,0,3840,1440</command>
            </action>
          </keybind>
        </keybind>
        <keybind key="KP_1">
          <keybind key="KP_1">
            <action name="Execute">
              <command>wmctrl -r :ACTIVE: -e 0,0,720,3840,720</command>
            </action>
          </keybind>
        </keybind>
      </keybind>
      <keybind key="KP_3">
        <keybind key="KP_0">
          <keybind key="KP_0">
            <action name="Execute">
              <command>wmctrl -r :ACTIVE: -e 0,0,0,5120,720</command>
            </action>
          </keybind>
          <keybind key="KP_1">
            <action name="Execute">
              <command>wmctrl -r :ACTIVE: -e 0,0,0,5120,1440</command>
            </action>
          </keybind>
        </keybind>
        <keybind key="KP_1">
          <keybind key="KP_1">
            <action name="Execute">
              <command>wmctrl -r :ACTIVE: -e 0,0,720,5120,720</command>
            </action>
          </keybind>
        </keybind>
      </keybind>
    </keybind>
    <keybind key="KP_1">
      <keybind key="KP_1">
        <keybind key="KP_0">
          <keybind key="KP_0">
            <action name="Execute">
              <command>wmctrl -r :ACTIVE: -e 0,1280,0,1280,720</command>
            </action>
          </keybind>
          <keybind key="KP_1">
            <action name="Execute">
              <command>wmctrl -r :ACTIVE: -e 0,1280,0,1280,1440</command>
            </action>
          </keybind>
        </keybind>
        <keybind key="KP_1">
          <keybind key="KP_1">
            <action name="Execute">
              <command>wmctrl -r :ACTIVE: -e 0,1280,720,1280,720</command>
            </action>
          </keybind>
        </keybind>
      </keybind>
      <keybind key="KP_2">
        <keybind key="KP_0">
          <keybind key="KP_0">
            <action name="Execute">
              <command>wmctrl -r :ACTIVE: -e 0,1280,0,2560,720</command>
            </action>
          </keybind>
          <keybind key="KP_1">
            <action name="Execute">
              <command>wmctrl -r :ACTIVE: -e 0,1280,0,2560,1440</command>
            </action>
          </keybind>
        </keybind>
        <keybind key="KP_1">
          <keybind key="KP_1">
            <action name="Execute">
              <command>wmctrl -r :ACTIVE: -e 0,1280,720,2560,720</command>
            </action>
          </keybind>
        </keybind>
      </keybind>
      <keybind key="KP_3">
        <keybind key="KP_0">
          <keybind key="KP_0">
            <action name="Execute">
              <command>wmctrl -r :ACTIVE: -e 0,1280,0,3840,720</command>
            </action>
          </keybind>
          <keybind key="KP_1">
            <action name="Execute">
              <command>wmctrl -r :ACTIVE: -e 0,1280,0,3840,1440</command>
            </action>
          </keybind>
        </keybind>
        <keybind key="KP_1">
          <keybind key="KP_1">
            <action name="Execute">
              <command>wmctrl -r :ACTIVE: -e 0,1280,720,3840,720</command>
            </action>
          </keybind>
        </keybind>
      </keybind>
    </keybind>
    <keybind key="KP_2">
      <keybind key="KP_2">
        <keybind key="KP_0">
          <keybind key="KP_0">
            <action name="Execute">
              <command>wmctrl -r :ACTIVE: -e 0,2560,0,1280,720</command>
            </action>
          </keybind>
          <keybind key="KP_1">
            <action name="Execute">
              <command>wmctrl -r :ACTIVE: -e 0,2560,0,1280,1440</command>
            </action>
          </keybind>
        </keybind>
        <keybind key="KP_1">
          <keybind key="KP_1">
            <action name="Execute">
              <command>wmctrl -r :ACTIVE: -e 0,2560,720,1280,720</command>
            </action>
          </keybind>
        </keybind>
      </keybind>
      <keybind key="KP_3">
        <keybind key="KP_0">
          <keybind key="KP_0">
            <action name="Execute">
              <command>wmctrl -r :ACTIVE: -e 0,2560,0,2560,720</command>
            </action>
          </keybind>
          <keybind key="KP_1">
            <action name="Execute">
              <command>wmctrl -r :ACTIVE: -e 0,2560,0,2560,1440</command>
            </action>
          </keybind>
        </keybind>
        <keybind key="KP_1">
          <keybind key="KP_1">
            <action name="Execute">
              <command>wmctrl -r :ACTIVE: -e 0,2560,720,2560,720</command>
            </action>
          </keybind>
        </keybind>
      </keybind>
    </keybind>
    <keybind key="KP_3">
      <keybind key="KP_3">
        <keybind key="KP_0">
          <keybind key="KP_0">
            <action name="Execute">
              <command>wmctrl -r :ACTIVE: -e 0,3840,0,1280,720</command>
            </action>
          </keybind>
          <keybind key="KP_1">
            <action name="Execute">
              <command>wmctrl -r :ACTIVE: -e 0,3840,0,1280,1440</command>
            </action>
          </keybind>
        </keybind>
        <keybind key="KP_1">
          <keybind key="KP_1">
            <action name="Execute">
              <command>wmctrl -r :ACTIVE: -e 0,3840,720,1280,720</command>
            </action>
          </keybind>
        </keybind>
      </keybind>
    </keybind>
<!-- windows management end -->
  </keybind>

It seems rather obvious to me, that you should be able to simplify this greatly, by having the ability to execute multiple actions at multiple levels, within nested keybindings, but I've not been able to get that to work, so that's that I suppose.

Next up, for me, finding a solution that can provide the same result, using only the arrow keys, working relative to the position of the window in question, much like you'd be able to do on some multi monitor systems, but for now, this'll do.

NB: I am using no window decorations, at all, if you do, that'll have to be taken into account.

Also, I'm perfectly aware, that this can be done a lot smart, just not how, and I'm simply to old to start using a tiling WM. I've tried it before, and my 3 second goldfish memory, just can't keep up. This way at least makes sense. thus I won't forget. If I can actually get used to it, well, that's a subject for another day.

Best regards and enjoy.


I am a philosopher, of sorts, not a troll or an imbecile.
My apologies that this is not always obvious, despite my best efforts.

Offline

Board footer

Powered by FluxBB