Tiling Windows in Openbox


There are basically two types of window managers: those that set-up the desktop workspace by stacking windows in an arbitrary fashion generally overlapping each other in an arbitrary fashion, and those that set-up windows in some kind of orderly manner that do not overlap and occupy approximately equal area. These are known as stacking and tiling window managers, respectively.

Openbox is a stacking window manager, but there is a simple shell script called winfuncs, which can be used to tile the openbox stacked windows at any time. Winfuncs is based on wmctrl, an old command line tool that provides access for doing many neat things to many modern Linux window managers. This is almost as good as having a tiling manager; it only fails in that new windows opened after a tile has been completed will not be automatically put into the tiling scheme. Each time a new window is opened the tiling button or key has to be re-applied to include it in the tiling. Winfuncs generates two tiling modes, one displays the open windows in a rectangular matrix mode assigning the same area to each window and one stacks the windows in an orderly, regular manner in the upper left corner of the screen. The following images show the initial arbitrary display by openbox of 6 open windows, the 6 windows after being tiled by winfuncs and the 6 windows after being stacked by winfuncs.


Winfuncs can be downloaded using wget from this website:

        wget http://lxlinux.com/winfuncs.

Put the winfuncs file in /usr/local/bin (on the path), and make it executable:

        sudo chmod 755 /usr/local/bin/winfuncs.

Make sure wmctrl, xdotool and x11-utils are installed:

        sudo apt-get install wmctrl xdotool x11-utils.

Now according to your desires, link up the winfunc commands to launch buttons on the desktop, in a panel or in a menu, or with keybindings. The execs are:

        winfuncs 'tile'        winfuncs 'cascade'                winfuncs 'tiletwo'        winfuncs 'showdesktop'.

winfuncs buttons
The "winfuncs 'tiletwo'" command makes the mouse pointer a selection tool. The next two subsequent single left-click on any part of any two open windows will bring those windows to the top, each occupying half the desktop. Double clinking a window will just bring that window to the top and ends the selection process. The "winfuncs 'showdesktop'" does just that, shows the desktop, while putting launchers to each open window in a panel taskbar. This is equivalent to the "iconofy" button that comes with most panels.

I generally use panel buttons to reflect these commands and remove the regular panel iconofy button. See the image on the right for my fbpanel setup. Panels have their own recipes for launch buttons. See Lxlinux - Fbpanel for information on doing this with fbpanel.