Ubuntu – How to “snap-split” windows top and bottom

compizmousesnap-windowswindowwindow-manager

One can share screenspace neatly in left and right portions by dragging the window until the cursor touches the left or right edge of the screen, and the window will automatically 'snap' to that half of the screen. How do I achieve this same functionality to share the screenspace in 'top' and 'bottom' halves instead of left and right?

I cannot do so when dragging the window until the cursor touches the top or bottom of the screen. Dragging to the top causes the window to maximize. Dragging to the bottom merely drops the rest of that window into the lower 'desktop screenspace'.

(Please also correct my terminology if there are designated words I should be using.)

Best Answer

A few year ago I wanted to achieve the snap window function in Lubuntu 14.04. I think you need openbox for this to work.

Take a look at https://github.com/lawl/opensnap


Below is a summary of the installation procedure quoted from that page:

Installing

If you want to install opensnap from source first make sure you have git installed. (Or fetch a zip file: https://github.com/lawl/opensnap/archive/master.zip)

Fetch via git:

git clone https://github.com/lawl/opensnap.git

Fetch via zip:

wget https://github.com/lawl/opensnap/archive/master.zip

unzip master.zip

Make sure you have all prerequisites:

sudo apt-get install build-essential libx11-dev libgtk-3-dev wmctrl

And finally build and install it:

cd opensnap*
make
sudo make install

And now start opensnap with

opensnap

or

opensnap --deamon

if you want it to daemonize.


If I remember well, there was a bug when trying to unsnap the snapped window. Take a look at https://github.com/lawl/opensnap/issues/4 there is a workaround described.

In my case Lubuntu 14.04 I had to modify /home/user/.config/openbox/lubuntu-rx.xml The code between the tags <mousebind button="Left" action="Drag"> and </mousebind> has to be exchanged by:

  <mousebind button="Left" action="Drag">
    <!-- Unsnap if snapped-->
    <action name="if">
      <maximizedvertical>yes</maximizedvertical>
      <then>
        <action name="Unmaximize"/>
          <direction>vertical</direction>
        <action name="MoveResizeTo">
          <x>center</x>
          <!-- we center windows in order to mitigate discrepancies 
          between window placement and mouse cursor -->
          <y>current</y>
        </action>
        <action name="Move"/>
      </then>
      <else>
        <action name="Move"/>
      </else>
    </action>
  </mousebind>

Make sure that you are inside the tags of <context name="Titlebar">