Organizing and Tiling Your Windows on #Openbox Using Only… Openbox

I’ve written before about using Openbox as my window manager – and even small utilities for it. And though I typically use a dual-monitor setup, it’s often a … busy place. But now it’s a slightly more organized and efficient busy place.

The blank area is because I have one monitor rotated into portrait mode.

I first stumbled across the idea of using tiling with xtile and then etile, and they worked pretty okay. But I would have liked something native to Openbox and with a bit more configuration. So I was thrilled to see Thomas Hunter’s post about treating Openbox like a tiling windowmanager.

However, I was already used to the keybinds I had with etile that focused on the keypad, and I wanted to have a number of options – basically each of the four corners, plus half-screen top and bottom. I also omitted the undecorating portion of his tutorial, simply because, well, I’d lose track otherwise. 🙂

These sections go in rc.xml, and I’ll quickly explain what they are. (You can get the whole thing in a gist, or cut and paste from here.)

    <!-- Keybindings for moving windows -->
    <keybind key="mod4-Left">
      <action name="GoToDesktop">
        <to>west</to>
        <wrap>yes</wrap>
      </action>
    </keybind>
    <keybind key="mod4-Right">
      <action name="GoToDesktop">
        <to>east</to>
        <wrap>yes</wrap>
      </action>
    </keybind>
    <keybind key="mod4-Up">
      <action name="SendToDesktop">
        <to>west</to>
      </action>
    </keybind>
    <keybind key="mod4-Down">
      <action name="SendToDesktop">
        <to>east</to>
      </action>
    </keybind>
    <keybind key="mod4-d">
      <action name="ToggleShowDesktop"/>
    </keybind>
    <keybind key="mod4-Super_R">
      <action name="MoveResizeTo">
        <monitor>next</monitor>
      </action>
    </keybind>

Basically this section allows me to use the Windows/Super/whatever key and the right/left arrow keys to move between desktops. And then I can use Super + up or down arrow keys to move the active window to the next or previous desktop (and to follow it). Super+d minimizes everything, and when I hit both Super keys at the same time, it moves the active window to the other display, which is super handy.

   <!-- Keybindings for tiling -->
    <keybind key="A-KP_5">
      <action name="ToggleMaximize"/>
    </keybind>
    <keybind key="A-KP_0">
      <action name="Iconify"/>
    </keybind>
    <keybind key="A-KP_4">
      <action name="Unmaximize"/>
      <action name="MoveResizeTo">
        <x>0</x>
        <y>0</y>
        <width>50%</width>
        <height>100%</height>
      </action>
    </keybind>
    <keybind key="A-KP_6">
      <action name="Unmaximize"/>
      <action name="MoveResizeTo">
        <x>-0</x>
        <y>0</y>
        <width>50%</width>
        <height>100%</height>
      </action>
    </keybind>
    <keybind key="A-KP_8">
      <action name="Unmaximize"/>
      <action name="MoveResizeTo">
        <x>0</x>
        <y>0</y>
        <width>100%</width>
        <height>50%</height>
      </action>
    </keybind>
    <keybind key="A-KP_2">
      <action name="Unmaximize"/>
      <action name="MoveResizeTo">
        <x>0</x>
        <y>-0</y>
        <width>100%</width>
        <height>50%</height>
      </action>
    </keybind>
    <keybind key="A-KP_7">
      <action name="Unmaximize"/>
      <action name="MoveResizeTo">
        <x>0</x>
        <y>0</y>
        <width>50%</width>
        <height>50%</height>
      </action>
    </keybind>
    <keybind key="A-KP_9">
      <action name="Unmaximize"/>
      <action name="MoveResizeTo">
        <x>-0</x>
        <y>0</y>
        <width>50%</width>
        <height>50%</height>
      </action>
    </keybind>
    <keybind key="A-KP_1">
      <action name="Unmaximize"/>
      <action name="MoveResizeTo">
        <x>0</x>
        <y>-0</y>
        <width>50%</width>
        <height>50%</height>
      </action>
    </keybind>
    <keybind key="A-KP_3">
      <action name="Unmaximize"/>
      <action name="MoveResizeTo">
        <x>-0</x>
        <y>-0</y>
        <width>50%</width>
        <height>50%</height>
      </action>
    </keybind>

These use Alt+keypad to move the active window to the cardinal positions, and Alt+KP5 to maximize it, and Alt+KP0 to minimize the window.

Finally, there’s moving between windows quickly. While I have Alt-Tab defined elsewhere, I used Alt and the keypad plus and minus keys to allow me to quickly cycle through windows – without a user dialog.

    <keybind key="A-KP_Add">
      <action name="NextWindow">
        <dialog>none</dialog>
        <raise>yes</raise>
        <linear>yes</linear>
        <allDesktops>yes</allDesktops>
        <interactive>no</interactive>
        <finalactions>
          <action name="Focus"/>
          <action name="Raise"/>
          <action name="Unshade"/>
        </finalactions>
      </action>
    </keybind>
    <keybind key="A-KP_Subtract">
      <action name="NextWindow">
        <dialog>none</dialog>
        <raise>yes</raise>
        <linear>yes</linear>
        <allDesktops>yes</allDesktops>
        <interactive>no</interactive>
        <finalactions>
          <action name="Focus"/>
          <action name="Raise"/>
          <action name="Unshade"/>
        </finalactions>
      </action>
    </keybind>

In the short while since I’ve put this workflow in place, it’s definitely made things easier for me and reduced my reliance on the mouse. If you’re using Openbox and want a pretty robust and native way to have some tiling on your desktop (or just a way to better organize your windows), check out Thomas’ post and adapt his (or my) setup as you like!