Tiling windows horizontally and vertically under Lubuntu (LXDE/Openbox)?

Solution 1:

Configuration:

Yes, you can achieve this by adding a few custom keyboard shortcuts to your openbox configuration file.

Open your rc.xml variant (e.g. ~/.config/openbox/lxde-rc.xml, ../lubuntu-rc.xml or ../rc.xml) and insert the following snippet within the <keyboard>..</keyboard> section:

<!-- Vertical tiling -->
<keybind key="C-W-v">
  <action name="UnmaximizeFull"/>
  <action name="MoveResizeTo">
    <width>50%</width>
  </action>
  <action name="MaximizeVert"/>
  <action name="MoveResizeTo">
    <x>0</x>
    <y>0</y>
  </action>
  <action name="NextWindow">
    <interactive>no</interactive>
    <dialog>none</dialog>
    <finalactions>
      <action name="UnmaximizeFull"/>
      <action name="MoveResizeTo">
        <width>50%</width>
      </action>
      <action name="MaximizeVert"/>
      <action name="MoveResizeTo">
        <x>-0</x>
        <y>0</y>
      </action>
    </finalactions>
  </action>
</keybind>

<!-- Horizontal tiling -->
<keybind key="C-W-h">
  <action name="UnmaximizeFull"/>
  <action name="MoveResizeTo">
    <height>50%</height>
  </action>
  <action name="MaximizeHorz"/>
  <action name="MoveResizeTo">
    <x>0</x>
    <y>0</y>
  </action>
  <action name="NextWindow">
    <interactive>no</interactive>
    <dialog>none</dialog>
    <finalactions>
      <action name="UnmaximizeFull"/>
      <action name="MoveResizeTo">
        <height>50%</height>
      </action>
      <action name="MaximizeHorz"/>
      <action name="MoveResizeTo">
        <x>0</x>
        <y>-0</y>
      </action>
    </finalactions>
  </action>
</keybind>

<!-- Restore window dimensions -->
<keybind key="C-W-r">
  <action name="UnmaximizeFull"/>
  <action name="NextWindow">
    <interactive>no</interactive>
    <dialog>none</dialog>
    <finalactions>
      <action name="UnmaximizeFull"/>
    </finalactions>
  </action> 
</keybind>

Shortcuts in action:

enter image description here

Usage:

  • Super+Ctrl+V: Tile last active windows vertically
  • Super+Ctrl+H: Tile last active windows horizontally
  • Super+Ctrl+R: Restore original window dimensions

To modify these assignments simply edit the <keybind key="..."> lines in the snippet above.

Notes:

  • This method will only tile the two last active windows
  • You can swap window positions by focussing the inactive window and pressing the hotkey again

Solution 2:

Glutanimate's answer (on this page) is excellent, but might benefit from a little extra info when applying this to Raspbian:

The openbox config file on Raspbian is .config/openbox/lxde-pi-rc.xml. It is "minified" so it's all one line of text, and doesn't contain a keyboard section by default.

A clean solution would be to open this file in something like VScode and change the formatting, then add the proper section, re-minify if you like, then copy that back onto the Pi.

I opted for quick and dirty, but functional:

  1. Open .config/openbox/lxde-pi-rc.xml with your choice of text editor
  2. Locate the string </openbox_config>, which is at the end of the really long "minified" line
  3. Put your cursor in front of that string and hit Enter a couple of times so it's on the next line with a space in between, like this:

    <?xml version="1.0"?>
    <openbox_config><theme><font place="ActiveWindow"><name>PibotoLt</name><size>16</size><weight>Normal</wei$
    
    </openbox_config>
    
  4. Add these lines in the space:

    <keyboard>
    
    </keyboard>
    
  5. Copy the lines from Glutanimate's answer between the <keyboard></keyboard> tags.

  6. Reload openbox to make the bindings active immediately: openbox --reconfigure

Solution 3:

Lubuntu LXDE already has simpler bindings with the Superkey+the desired arrow key See below and just try it before modifying the rc.xml unless you need to change the keys.

<keybind key="W-Left">        # HalfLeftScreen
      <action name="UnmaximizeFull"/>
      <action name="MoveResizeTo"><x>0</x><y>0</y><height>100%</height><width>50%</width></action>
    </keybind>
    <keybind key="W-Right">        # HalfRightScreen
      <action name="UnmaximizeFull"/>
      <action name="MoveResizeTo"><x>-0</x><y>0</y><height>100%</height><width>50%</width></action>
    </keybind>
    <keybind key="W-Up">        # HalfUpperScreen
      <action name="UnmaximizeFull"/>
      <action name="MoveResizeTo"><x>0</x><y>0</y><width>100%</width><height>50%</height></action>
    </keybind>
    <keybind key="W-Down">        # HalfLowerScreen
      <action name="UnmaximizeFull"/>
      <action name="MoveResizeTo"><x>0</x><y>-0</y><width>100%</width><height>50%</height></action>
    </keybind>

I also modified the config to add 1/4 screen so 4 windows can be set in each corner along with a toggle maximize hotkey. Superkey+Alt+plus arrow. Superkey+Ctrl+Up to toggle maximize.

<keybind key="W-A-Left">      # 1/4LeftUpperScreen
  <action name="UnmaximizeFull"/>
  <action name="MoveResizeTo"><x>0</x><y>0</y><height>50%</height><width>50%</width></action>
</keybind>
<keybind key="W-A-Right">     # 1/4RightLowerScreen
  <action name="UnmaximizeFull"/>
  <action name="MoveResizeTo"><x>-0</x><y>-0</y><height>50%</height><width>50%</width></action>
</keybind>
<keybind key="W-A-Up">        # 1/4RightUpperScreen
  <action name="UnmaximizeFull"/>
  <action name="MoveResizeTo"><x>-0</x><y>0</y><width>50%</width><height>50%</height></action>
</keybind>
<keybind key="W-A-Down">      # 1/4LeftLowerScreen
  <action name="UnmaximizeFull"/>
  <action name="MoveResizeTo"><x>0</x><y>-0</y><width>50%</width><height>50%</height></action>
</keybind>
<keybind key="W-C-Up">      # ToggleMaximize
  <action name="ToggleMaximize"/>
</keybind>