Windows 7-style Snapping Windows in Ubuntu Linux 10.04 (Lucid)
Having spent too many long hours at work with a Windows 7 machine, it’s really awkward going back to Ubuntu and not having windows snap to the edges when I drag windows to the edge of the screen. Luckily, it’s rather easy to customize Compiz (the default window manager for Ubuntu) so that it acts in this way. Most of these instructions can already be found on Google, but I’m compiling them here for future reference. Windows 7 only allows three main types of snapping – left half, right half, and full screen by dragging the window to the left, right, and top of the screen respectively, although the grid plugin I’m using below lets you dock windows in all the obvious places so feel free to adjust the procedure as you see fit. These instructions have only been tested on a single-monitor setup, but then again, even Windows 7 acts funny when you try to use Aero Snap (or whatever it’s called) on a dual-head setup. (If the monitors are side-by-side, snapping to the top snaps full screen to the current monitor. You can only snap to the left-most edge of the left-most monitor, and likewise for the right-most monitor. I haven’t tested Aero Snap for two monitors that are arranged vertically; and don’t intend on doing so in the near future.) Before You Begin You will need to install the following packages if they’re not already installed: - compizconfig-settings-manager - compiz-fusion-plugins-extra - xautomation
Most of this software isn’t “officially supported” by Canonical, but that shouldn’t stop you from using it in most cases. You may need to add additional repositories in order to install the packages. For the lazy, you can just enter the following command into a terminal. (Note: If you don’t understand what the following command does, it is highly recommended that you use Synaptic Package Manager to install the software yourself instead.)
sudo aptitude install compizconfig-settings-manager compiz-fusion-plugins-extra xautomation
Open the CompizConfig Settings Manager Click System | Preferences | CompizConfig Settings Manager. If you can’t find this menu item, make sure that you installed the compizconfig-settings-manager package. Enable the Grid Plugin Click the Window Management category. Select Grid. If Grid does not appear, make sure you installed the compiz-fusion-plugins-extra package. Note the default key shortcuts. The key shortcuts use Ctrl and Alt, as well as the keypad numeric keys (not to be confused with the number keys above the letters on your keyboard). So KP6 corresponds to the 6 key on the keypad. If you change these, you will need to update the parameters given to xte, below. Enable the Grid Plugin. Create Edge Bindings Click the All category. Click Commands Here we will create commands using the xte program that will trigger the keyboard shortcuts for the Grid plugin.
xte 'keydown Control\_L' 'keydown Alt\_L' 'key KP\_4' 'keyup Control\_L' 'keyup Alt\_L' xte 'keydown Alt\_L' 'key F10' 'keyup Alt\_L' xte 'keydown Control\_L' 'keydown Alt\_L' 'key KP\_6' 'keyup Control\_L' 'keyup Alt\_L'
After entering the commands, the screen should look like this. Update: Setting command 1 (the top edge binding) to read ALT-F10 (instead of Ctrl-Alt-KP_5 as per the screen shot) will cause the current window to be “properly” maximized. Using the old method will allow you to toggle maximizing by moving the mouse to the top edge, which may be confusing. Click the Edge bindings tab. To set the bindings for the commands we created earlier (click the button that says None). Select the edge in this window. If you get this pop-up, disable the other binding. Here are the finished edge bindings. Adjust Edge Trigger Delay If you use it now, just touching the edge will cause the window to change size, which is annoying. So we set an edge trigger delay. Click General Options General Options Adjust the edge trigger delay by using the mouse or entering a value. A value of 400-500 ms is reasonable, but feel free to adjust it. Final Thoughts Voila! The finished product. Of course, this “emulation” isn’t perfect: - You won’t get the huge blue silhouette of the window’s new position. - The binding will trigger regardless of whether you are dragging a window or whether you just leave the mouse cursor at the edge of the screen - If a window has a minimum size, when the window is resized by the grid plugin, it may take up more than half the screen.
But it does the job, for someone who’s used to gestures introduced in Windows 7 and can’t be bothered to resize windows manually any more.