Monday, January 17, 2011

Aero Snap Keyboard Shortcuts in Ubuntu

I wanted the "Aero Snap" functionality in Windows 7 to work on my fresh Ubuntu 10.10 install. In case you are not familiar, this allows a window to snap to a certain position. I have a widescreen monitor that is wide enough to comfortably have two windows side by side. Arranging this by hand is a pain. The snap feature will automatically resize a window to maximum vertical and half the width of the screen on either side. In Windows 7 you can either drag the window to the sides of the desktop or you can use the Windows key + arrows shortcuts. I was mostly interested in the shortcuts.

I found the basic solution at Get Aero Snap in Ubuntu

The instructions as given did not quite work for me so I just hardcoded in the width of my screen:

WIDTH=1920 && HALF=$(($WIDTH/2)) && wmctrl -r :ACTIVE: -b add,maximized_vert && wmctrl -r :ACTIVE: -e 0,0,0,$HALF,-1
WIDTH=1920 && HALF=$(($WIDTH/2)) && wmctrl -r :ACTIVE: -b add,maximized_vert && wmctrl -r :ACTIVE: -e 0,$HALF,0,$HALF,-1
wmctrl -r :ACTIVE: -b toggle,maximized_vert,maximized_horz

Note that I did not need to change the last entry for going full screen. Then under the General Options of the Compiz Settings Manager I just mapped Key Bindings rather than Edge Bindings.

Command 0 to Windows Key + Left Arrow
Command 1 to Windows Key + Right Arrow
Command 2 to Windows Key + Up Arrow

2 comments:

  1. Well done. I'm on 11.04. The aero snap is great; this completes the pie.

    ReplyDelete
  2. Compiz... same but more. This is cool though if you don't want to install Compiz...

    ReplyDelete