19

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?

4 Answers 4

8

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

3

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.

3
  • 1
    does this work for someone? cheers
    – type
    Dec 3, 2011 at 17:15
  • Don't think this is working for Unity2D which the OP clearly stated. I am kind of confused as to what the negative shape is referring to.
    – chzbrgla
    Feb 5, 2012 at 13:23
  • I could not get the behaviour to work in Unity 2D with the above solution. The commands are fine when issued from a terminal window but compiz Command plugin doesn't allow &&. Instead I could solve this by putting the commands into separate .sh files and put sh /path/to/script.sh into the command lines in compiz. Mar 23, 2012 at 13:08
2

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

1

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

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

1
  • You can also run it with --daemonize to use the built-in keybinding and it'll be more responsive because it doesn't have to start, perform the action, and then quit every time you press a key.
    – ssokolow
    Oct 25, 2012 at 20:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .