Saturday, December 18, 2010

Dual Monitor Aero Snap in Ubuntu

I think the coolest thing about Windows 7 is Aero Snap. It really helps you get more efficient use of your screen real estate without you have to manually resize your windows. The good people at OMG! Ubuntu posted a great tutorial on how to get Aero Snap in Ubuntu. I followed the tutorial and got my laptop snapping perfectly. I was not so lucky on my dual monitor desktop. So I have modified the script slightly to make it so it will now work on dual screen monitors. Most of this is exactly the same as the OMG! Ubuntu tutorial, so if you feel I didn't explain something clearly you should reference theirs.

Step 1 - Install Compiz Config

sudo apt-get install compizconfig-settings-manager wmctrl

Step 2 - Set up the commands

  • Open the Compiz Config manager (System -> preferences -> CompizConfig Settings Manager)

  • Select the "Commands" option

  • In "Command Line 0" past:

WIDTH=`xdpyinfo | grep 'dimensions:' | cut -f 2 -d ':' | cut -f 1 -d 'x'` && HALF=$(($WIDTH/4)) && wmctrl -r :ACTIVE: -b add,maximized_vert && wmctrl -r :ACTIVE: -e 0,0,0,$HALF,-1

  • In "Command Line 1" past:

WIDTH=`xdpyinfo | grep 'dimensions:' | cut -f 2 -d ':' | cut -f 1 -d 'x'` && HALF=$(($WIDTH/4)) && LOCATION=$(($WIDTH-$HALF)) && wmctrl -r :ACTIVE: -b add,maximized_vert && wmctrl -r :ACTIVE: -e 0,$LOCATION,0,$HALF,-1

  • In "Command Line 2" past:

wmctrl -r :ACTIVE: -b add,maximized_vert,maximized_horz

Step 3 - Enable the commands
Go to the 'Edge Bindings' tab and set the following:

  • Run Command 0 - Set to Left

  • Run Command 1 - Set to Right

  • Run Command 2 - Set to Top

Good luck, let me know if you have any questions.