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:
- How to resize windows using hot keys to fill 50% of the screen? - Support - Lubuntu Discourse
- Lubuntu 20.04 - Super+Left shortcut is not functional where other direction work - Ask Ubuntu
- shortcut keys - Lubuntu 19.10 & 20.04: How to tile windows? The window tiling section is missing in lxqt-rc.xml - Ask Ubuntu
Comments
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.
Thanks.
@Sam Thank you for this blog entry, very helpful <3