Manual Tiling in Openbox

October 30, 2011

Occasionally I want to tile two or three windows. In the past I’ve used tile or whaw for this. I also know of such applications like Pytyle. But all of these require me to have an additional application installed or a daemon running to tile my windows, which is too much work for the few times I want to tile my windows.

A while ago, aeiah of the Ubuntu Forums, told me of how he manually tiles windows in Openbox, using its MoveResizeTo action. He explains it at some length in this post. It takes some fiddling to get the settings right for your own monitor, but once you have it set up it is a great tool to quickly tile a handful of windows.

I have these actions bound to a keychain, beginning with Win + a (which I use for all my window actions), followed by the number of the numeric keypad that corresponds to the place I want the window to appear: 7 is upper left half, 3 the lower right half, 4 the left 60% of the screen, 6 the remainder of the right side of the screen, and so on. This allows me to quickly tile two or three windows, and only the windows I want (rather than all the windows in the current workspace), which is exactly what I wanted.

These are the settings I use for my 2048×1152 monitor:

   <keybind key="W-a">
<!-- Begin the keychains to manage windows -->
      <!-- aeiah's semi-tiling mode -->
      <keybind key="KP_6">
        <action name="UnmaximizeFull"/>
        <action name="MoveResizeTo">
          <x>1110</x>
          <y>0</y>
          <width>940</width>
          <height>1108</height>
        </action>
      </keybind>
      <keybind key="KP_4">
        <action name="UnmaximizeFull"/>
        <action name="MoveResizeTo">
          <x>0</x>
          <y>0</y>
          <width>1108</width>
          <height>1108</height>
        </action>
      </keybind>
      <keybind key="KP_8">
        <action name="UnmaximizeFull"/>
        <action name="MoveResizeTo">
          <x>0</x>
          <y>0</y>
          <width>2048</width>
          <height>576</height>
        </action>
      </keybind>
      <keybind key="KP_2">
        <action name="UnmaximizeFull"/>
        <action name="MoveResizeTo">
          <x>0</x>
          <y>564</y>
          <width>2048</width>
          <height>564</height>
        </action>
      </keybind>
      <keybind key="KP_9">
        <action name="UnmaximizeFull"/>
        <action name="MoveResizeTo">
          <x>1110</x>
          <y>0</y>
          <width>940</width>
          <height>554</height>
        </action>
      </keybind>
      <keybind key="KP_3">
        <action name="UnmaximizeFull"/>
        <action name="MoveResizeTo">
          <x>1110</x>
          <y>571</y>
          <width>940</width>
          <height>546</height>
        </action>
      </keybind>
      <keybind key="KP_1">
        <action name="UnmaximizeFull"/>
        <action name="MoveResizeTo">
          <x>0</x>
          <y>440</y>
          <width>720</width>
          <height>420</height>
        </action>
      </keybind>
      <keybind key="KP_7">
        <action name="UnmaximizeFull"/>
        <action name="MoveResizeTo">
          <x>0</x>
          <y>0</y>
          <width>720</width>
          <height>420</height>
        </action>
      </keybind>
<!-- other keychains to manage windows -->
    </keybind>

As aeiah mentioned, this method does not let you ‘untile’ windows. I have added another action to my rc.xml to allow me to untile the window, using the MoveResizeTo action. This action, bound to Win + a + r, moves the window to the centre of the screen and resizes it to a 800×1100 size, which is about the size I have most of my windows. Here is the relevant part of my rc.xml:

   <keybind key="W-a">
<!-- Begin the keychains to manage windows -->
    <keybind key="r">
    <action name="MoveResizeTo">
	<x>center</x>
	<y>center</y>
	<height>800</height>
	<width>1100</width>
    </action>
    </keybind>
<!-- other keychains to manage windows -->
    </keybind>

If you generally maximize your windows, as I do on my much smaller laptop screen, you could easily add a command to maximize the window again, using the Maximize or ToggleMaximize actions. If there are only a few applications you do not maximize, you can use the really nifty if action. (This works only in Openbox 3.5) For example, if I want to maximize all windows except Thunar, which I want to move to the centre and resize to a 800×600 size, I could use the following keybinding:

 <keybind key="W-a">
<!-- Begin the keychains to manage windows -->
<keybind key="r">
 <action name="If">
     <title>* File Manager</title>
  <then>
   <action name="MoveResizeTo">
	<x>center</x>
	<y>center</y>
	<height>600</height>
	<width>800</width>
    </action>
  </then>
  <else>
     <action name="Maximize"/>
  </else>
 </action>
</keybind>
<!-- other keychains to manage windows -->
</keybind>

To navigate between tiled windows you could use the DirectionalTargetWindow or the DirectionalCycleWindows actions (if you want to see a dialog). I had these bound to Win + the appropriate numeric keypad key, but never use them. Someone else might find these actions useful, though.

About these ads

7 Responses to “Manual Tiling in Openbox”

  1. Robert Cox said

    Awesome post. Glad someone has got this documented now.

  2. Hi,

    Instead of using absolute size values, openbox’s also supports sizes based in fractions of the current window size (e.g., 50%, 25% and so on). Example:

    50%

    50%

  3. Rick R said

    I’ve been experimenting with several tiling WM’s, but am not the only person using the computer and needed something that would allow me that option, without having to change from Openbox. It took about 20 minutes to reposition xy’s and I used the % values. Neat and thanks

  4. Hago said

    Thank you, thank you, thank you! I’ve tried _every single_ tiling WM and kept returning to Openbox. This blog is great!

  5. [...] you would probably want to use Openbox’ own actions, instead of wmctrl. Have a look at this post for ideas on how to set this up. Posted by urukrama Filed in pekwm Leave a Comment [...]

  6. Arto said

    There is an easier way to do it: sudo apt-get install i3

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 80 other followers