Get back standard window snapping in Lubuntu (20.04 and newer)

Older versions of Lubuntu, using the LXDE desktop, had a very handy keyboard shortcut for snapping windows to the left, right, top, or bottom sides of the screen. This was done with the Super key ("Windows" logo key) and the arrow keys. 

It was a convenient feature if you wanted two windows lined up automatically side by side, and worked similarly to window snapping as done in Windows and other Ubuntu versions when dragging a window to the side edge, but was lighter on system resources.

Windows snapped to right and left via keyboard shortcut in Lubuntu 20.04 (LXQt)


But in newer versions of Lubuntu (at least as of 20.04) using the LXQT desktop, window snapping has been removed. 

This was a feature I used all the time, so I was eager to get it back. Luckily, we can. It's not too hard but it does take a few steps.

Getting back the old style window snapping


For this post I will assume you want window snapping to work exactly the way it did in older versions of Lubuntu. I was using 18.04 until recently and reluctantly upgraded. I want it to work exactly as it did before so that's what I'm doing. Feel free to use this as a guide, because you can set nearly any key combination you want for this. I simply want the same Super-Arrows type key shortcut that came installed in 18.04 by default.

Step 1: Disable the Super key 


By default in LXQT the Super key opens the main menu (aka the Start menu, in the bottom-left corner). This interferes with using the key for window snapping, so we will disable it for that purpose. 

Menu > Preferences > LXQt settings > Shortcut Keys

Find the entry for "Super_L" and simple uncheck it.

Global LXQt shortcuts list


If you like having a key to open the menu, just choose a different key combo. 

Step 2: Paste the window snapping code


Next, we need to tell the windows manager how to do window snapping with our desired keys. All it means is pasting a piece of text into a file. We don't even need sudo for this. Just go to your home folder and find this file:

/home/YOURUSERNAME/.config/openbox/lxqt-rc.xml

Open the file in Featherpad or any other plain text editor, and find this tag:

</keyboard>

Right above that tag, paste in the following code:

   <!-- Window snapping code we are adding -->
   <keybind key="Super-Left">
  <action name="UnmaximizeFull"/>
  <action name="MoveResizeTo">
    <width>50%</width>
    <height>100%</height>
    <x>0%</x>
    <y>0%</y>
  </action>
</keybind>
<keybind key="Super-Right">
  <action name="UnmaximizeFull"/>
  <action name="MoveResizeTo">
    <width>50%</width>
    <height>100%</height>
    <x>50%</x>
    <y>0%</y>
  </action>
</keybind>
<keybind key="Super-Down">
  <action name="UnmaximizeFull"/>
  <action name="MoveResizeTo">
    <width>100%</width>
    <height>50%</height>
    <x>0%</x>
    <y>50%</y>
  </action>
</keybind>
<keybind key="Super-Up">
  <action name="UnmaximizeFull"/>
  <action name="MoveResizeTo">
    <width>100%</width>
    <height>50%</height>
    <x>0%</x>
    <y>0%</y>
  </action>
</keybind>   

It should look like this:

Openbox config file for LXQt, with window snapping code re-added


Note again that you can edit the keybind keys to other combinations. For example if you don't like using the Windows key and the left arrow ("Super-Left") you can use something like Ctrl-Alt-Left in which case you'd change it to C-A-Left. But I like the old 18.04 way of snapping windows so I'm keeping it with the Super key.

Now just save the file

Step 3 - Refresh


You don't even need to log-out or restart to get it working now. Just run this command in a terminal:

openbox --reconfigure

That's it. Happy snapping.


Sources:

Comments

npl said…
Crystal clear, and works. Thanks.
Peter said…
Hello,
This was great! Having updated to Lubuntu 20.04 I was disappointed window 'snapping' was removed.
I tried your advice and it worked. I then upgraded Lubuntu as a message appeared the window snapping no longer works again. What do I do please?
Thanks for any advice.
Peter said…
Okay, now it works again. I went into Menu > Preferences > LXQt settings > Shortcut Keys and ENABLED Super L. So, before upgrade you have to disable Super L and after upgrade you have to disable Super L.
Peter said…
This worked. Then it stopped working. Now I don't know why. Please help!!
Thanks.
Anonymous said…
It is not a ideal solution, but you can go to Preferences>LXQT Settings>Session Settings and disable "Global Keyboard Shortcuts". This makes window snapping work for me, but I now noticed that ctrl+alt+t doesn't work anymore for bringing up the terminal.
Unknown said…
Wow. Thanks so much for this clear and perfect guide! It is so strange they decided to remove this wonderful feature. Fortunately there was this blog :)
Unknown said…
True @Peter, the same happened here... At least I am glad it is working again xD

@Sam Thank you for this blog entry, very helpful <3