snap your window to the left or right

This script will snap your window to the left or right side of the screen in Linux: (SOURCE)

## ${HOME}/bin/wmctrl-snap-edge
test -x "/usr/bin/xdpyinfo" -a -x "$WMCTRL" || {
    echo "error"; exit 1; }

WIDTH=`xdpyinfo | sed -n 's/ *dimensions: *\([0-9]*\)x.*/\1/p'`
HALF=$(($WIDTH / 2));
"$WMCTRL" -r :ACTIVE: -b add,maximized_vert;
if test "$1" = "left" ; then
	"$WMCTRL" -r :ACTIVE: -e 0,0,0,$HALF,-1
elif test "$1" = "right" ; then
	"$WMCTRL" -r :ACTIVE: -e 0,$HALF,0,$HALF,-1

If you don't have wmctrl installed, you can apt-get it (Ubuntu):

sudo apt-get --yes install wmctrl
Or compile it yourself:
sudo yum install libXmu-devel
cd /tmp
wget ''
tar --extract --gzip --file "wmctrl-1.07.tar.gz"
cd wmctrl-1.07
make -j 4
mv wmctrl ${HOME}/bin/wmctrl_`arch`

The next step is to set up hotkeys. If you use Metacity like I do, then:

gconftool-2 --type string --set \
	/apps/metacity/global_keybindings/run_command_6 \

gconftool-2 --type string --set \
	/apps/metacity/keybinding_commands/command_6 \
	"${HOME}/bin/wmctrl-snap-edge left"

gconftool-2 --type string --set \
	/apps/metacity/global_keybindings/run_command_7 \

gconftool-2 --type string --set \
	/apps/metacity/keybinding_commands/command_7 \
	"${HOME}/bin/wmctrl-snap-edge right"