Ubuntu – What’s the best way to implement a script for tiling windows

11.04command linedisplaywindow-manager

I just upgraded to ubuntu 11.04, and I am looking for a good way to tile windows. What I need is just to move window to the left or right half side of the screen, and bind the actions to some keyboard shortcuts. For instance move-window-to-display.sh contains

#!/bin/bash

if [ $1 -eq 2 ]
then
    POS="950 0"
    SIZE="967 1031"
else
    POS="0 0"
    SIZE="965 1031"
fi

xdotool windowmove `xdotool getwindowfocus` $POS
xdotool windowsize `xdotool getwindowfocus` $SIZE

exit 0

Then ". move-window-to-display.sh 1" moves the window to the left and ". move-window-to-display.sh 2" to the right. However, this code works but not perfectly, because of xdotool I guess, anyway it is not easy to put the windows at the exact position that we want.

So does anyone have a better way to do this? Either by Shell or by other tools… I tried tiling window manager like xmonad, but it seems too complicated to use…

Thank you very much

Best Answer

You can achieve this in Compiz, the default window manager.

First, launch CompizConfig Settings Manager by pressing super+a or by clicking on the applications icon then typing 'compiz config' and selecting 'CompizConfig Settings Manager'. If it is not installed, the Software Centre will open so you can install it.

launch ccsm

Then, click on 'Grid' in the window management section.

ccsm

You can then configure the key bindings for putting the window to either side of the screen.

enter image description here

Click on the description of each key binding to change it.

enter image description here