Is there any way I can tile two windows horizontally (⬒) or vertically (◧ ) under Lubuntu/LXDE/Openbox? Maybe via a keyboard shortcut or panel button?
3 Answers
Configuration:
Yes, you can achieve this by adding a few custom keyboard shortcuts to your openbox configuration file.
Open your rc.xml
variant (e.g. ~/.config/openbox/lxde-rc.xml
, ../lubuntu-rc.xml
or ../rc.xml
) and insert the following snippet within the <keyboard>..</keyboard>
section:
<!-- Vertical tiling -->
<keybind key="C-W-v">
<action name="UnmaximizeFull"/>
<action name="MoveResizeTo">
<width>50%</width>
</action>
<action name="MaximizeVert"/>
<action name="MoveResizeTo">
<x>0</x>
<y>0</y>
</action>
<action name="NextWindow">
<interactive>no</interactive>
<dialog>none</dialog>
<finalactions>
<action name="UnmaximizeFull"/>
<action name="MoveResizeTo">
<width>50%</width>
</action>
<action name="MaximizeVert"/>
<action name="MoveResizeTo">
<x>-0</x>
<y>0</y>
</action>
</finalactions>
</action>
</keybind>
<!-- Horizontal tiling -->
<keybind key="C-W-h">
<action name="UnmaximizeFull"/>
<action name="MoveResizeTo">
<height>50%</height>
</action>
<action name="MaximizeHorz"/>
<action name="MoveResizeTo">
<x>0</x>
<y>0</y>
</action>
<action name="NextWindow">
<interactive>no</interactive>
<dialog>none</dialog>
<finalactions>
<action name="UnmaximizeFull"/>
<action name="MoveResizeTo">
<height>50%</height>
</action>
<action name="MaximizeHorz"/>
<action name="MoveResizeTo">
<x>0</x>
<y>-0</y>
</action>
</finalactions>
</action>
</keybind>
<!-- Restore window dimensions -->
<keybind key="C-W-r">
<action name="UnmaximizeFull"/>
<action name="NextWindow">
<interactive>no</interactive>
<dialog>none</dialog>
<finalactions>
<action name="UnmaximizeFull"/>
</finalactions>
</action>
</keybind>
Shortcuts in action:
Usage:
- Super+Ctrl+V: Tile last active windows vertically
- Super+Ctrl+H: Tile last active windows horizontally
- Super+Ctrl+R: Restore original window dimensions
To modify these assignments simply edit the <keybind key="...">
lines in the snippet above.
Notes:
- This method will only tile the two last active windows
- You can swap window positions by focussing the inactive window and pressing the hotkey again
-
1Me likey the animated gif... just wish you could have worked in blink and marquee tags as well!! :) -But really, good use of the gif. Commented Aug 27, 2014 at 10:17
-
2Do not forget to execute command
openbox --reconfigure
to use your changed settings.– EvmorovCommented Mar 28, 2015 at 19:19 -
To bind NumPad keys use KP_1 ... KP_9 keys:
<keybind key="C-A-KP_1">
= Ctr+Alt+NumPad1 or<keybind key="W-KP_1">
= SuperKey+NumPad1. See openbox documentation.– Y.B.Commented May 15, 2017 at 20:17 -
1
Lubuntu LXDE already has simpler bindings with the Superkey+the desired arrow key See below and just try it before modifying the rc.xml unless you need to change the keys.
<keybind key="W-Left"> # HalfLeftScreen
<action name="UnmaximizeFull"/>
<action name="MoveResizeTo"><x>0</x><y>0</y><height>100%</height><width>50%</width></action>
</keybind>
<keybind key="W-Right"> # HalfRightScreen
<action name="UnmaximizeFull"/>
<action name="MoveResizeTo"><x>-0</x><y>0</y><height>100%</height><width>50%</width></action>
</keybind>
<keybind key="W-Up"> # HalfUpperScreen
<action name="UnmaximizeFull"/>
<action name="MoveResizeTo"><x>0</x><y>0</y><width>100%</width><height>50%</height></action>
</keybind>
<keybind key="W-Down"> # HalfLowerScreen
<action name="UnmaximizeFull"/>
<action name="MoveResizeTo"><x>0</x><y>-0</y><width>100%</width><height>50%</height></action>
</keybind>
I also modified the config to add 1/4 screen so 4 windows can be set in each corner along with a toggle maximize hotkey. Superkey+Alt+plus arrow. Superkey+Ctrl+Up to toggle maximize.
<keybind key="W-A-Left"> # 1/4LeftUpperScreen
<action name="UnmaximizeFull"/>
<action name="MoveResizeTo"><x>0</x><y>0</y><height>50%</height><width>50%</width></action>
</keybind>
<keybind key="W-A-Right"> # 1/4RightLowerScreen
<action name="UnmaximizeFull"/>
<action name="MoveResizeTo"><x>-0</x><y>-0</y><height>50%</height><width>50%</width></action>
</keybind>
<keybind key="W-A-Up"> # 1/4RightUpperScreen
<action name="UnmaximizeFull"/>
<action name="MoveResizeTo"><x>-0</x><y>0</y><width>50%</width><height>50%</height></action>
</keybind>
<keybind key="W-A-Down"> # 1/4LeftLowerScreen
<action name="UnmaximizeFull"/>
<action name="MoveResizeTo"><x>0</x><y>-0</y><width>50%</width><height>50%</height></action>
</keybind>
<keybind key="W-C-Up"> # ToggleMaximize
<action name="ToggleMaximize"/>
</keybind>
Glutanimate's answer (on this page) is excellent, but might benefit from a little extra info when applying this to Raspbian:
The openbox config file on Raspbian is .config/openbox/lxde-pi-rc.xml
. It is "minified" so it's all one line of text, and doesn't contain a keyboard section by default.
A clean solution would be to open this file in something like VScode and change the formatting, then add the proper section, re-minify if you like, then copy that back onto the Pi.
I opted for quick and dirty, but functional:
- Open
.config/openbox/lxde-pi-rc.xml
with your choice of text editor - Locate the string
</openbox_config>
, which is at the end of the really long "minified" line Put your cursor in front of that string and hit Enter a couple of times so it's on the next line with a space in between, like this:
<?xml version="1.0"?> <openbox_config><theme><font place="ActiveWindow"><name>PibotoLt</name><size>16</size><weight>Normal</wei$ </openbox_config>
Add these lines in the space:
<keyboard> </keyboard>
Copy the lines from Glutanimate's answer between the
<keyboard></keyboard>
tags.- Reload openbox to make the bindings active immediately:
openbox --reconfigure