How do I get Aero Snap in Unity 2D?

I really miss the "Aero Snap" window snapping feature present in Unity 3D. Is there any way I can get it, or an alternative to it, in Unity 2D?


Solution 1:

11.10 and above

The fully fledged Aero-snap is a compiz feature.

If compiz is too heavy/problematic for your PC, then you could use a modified window manager such as xfwm4

enter image description here

By dragging the windows to the top/bottom/left or right, the window will snap to that part of the screen. Dragging via the titlebar will revert its original size.

The nice-side effect of using xfwm4 is that you get the nice GUI tweak tools to modify the keyboard/decorators etc:

  • xfwm4-settings - style/keyboard shortcuts/window focus model/window snapping control
  • xfwm4-tweaks-settings - window cycling/nice lightweight compositor and much more
  • xfwm4-workspace-settings - define the number of workspaces you will use.

how-to

The modified window-snap is available in my PPA

sudo add-apt-repository ppa:fossfreedom/xfwm4
sudo apt-get upgrade
sudo apt-get install xfwm4

recommendation

By default, this window manager does not integrate with the global menu.

Two suggestions -

Suggestion 1:

Remove the global menu if you use maximised windows alot of the time since the xfwm4 decorations do not integrate with the gnome-panel.

sudo apt-get remove indicator-appmenu

Use xfwm4 --replace as a startup application to use this window manager instead of metacity.

Suggestion 2:

Use maximus to remove the window decoration for maximised windows as per this Q&A:

Mutter: Global menu integration

Solution 2:

This doesn't work as well as the feature in Unity 3D, but it does work to some extent. My solution uses keyboard shortcuts, but you could easily use Edge Bindings (ie. left, right and top) instead to trigger the effect.

  1. Install packages. Paste (Ctrl+Shift+V) this in terminal: sudo apt-get install compizconfig-settings-manager compiz-fusion-plugins-extra wmctrl

  2. Now open the Compiz Config Settings Manager (ALT+F2 ccsm, or system > preferences > CompizConfig…, etc). Select the “Commands” option.

  3. In 'Command Line 0' paste: -

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

    WIDTH=`xdpyinfo | grep 'dimensions:' | cut -f 2 -d ':' | cut -f 1 -d 'x'` && HALF=$(($WIDTH/2)) && wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz && wmctrl -r :ACTIVE: -b add,maximized_vert && wmctrl -r :ACTIVE: -e 0,$HALF,0,$HALF,-1
    
  5. And in 'Command Line 2' paste: -

    wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz
    
  6. Now go to 'Key Bindings'. Click on the button for 'Run Command 0', enable it and grab this key combination: press "start button" and the left arrow. Do the same for all of the commands, so it's like this:

    • Run Command 0 ~ Left
    • Run Command 1 ~ Right
    • Run Command 2 ~ Top

NB: you can install the grid plugin (like in Unity 3D) which lets you use Ctrl+Alt+6 [Num Pad] etc to snap windows into a grid. However, I can't remember how to use window edges for this.

Solution 3:

You can also use wmctrl for Aero snap, which has the following benefits:

  1. You don't have to mess about with Compiz.
  2. You can run it from within Gnome (Unity2D) without having to install another window manager.

I wrote a Python script to set up the commands. All you need to do is:

  1. Adjust the resolution to match your display
  2. Assign keyboard shortcuts to the commands it creates

http://pastebin.com/T6StxqQd

Solution 4:

I've had better luck with quicktile. Use it the same way, create shortcuts to the command.

http://ssokolow.github.com/quicktile/