As we all know, Openbox is a floating window manager. For mouse user it maybe easy, but for me that always lazying and use laptop in my bed, it’s hard to navigate, especially when i want to see multiple windows at once. That’s where tiling needed. Unlike in tiling window manager, we must bind keys to tile our window, so i called it Pseudo-Tiling.
I have two ways to tile window in openbox. Using only
rc.xml config and using bash script and bind it in
rc.xml. Each one of them has it’s pros and cons. In this article I will explain both of them.
We can’t really using openbox without
rc.xml. Almost all of openbox configs are stored there, from keybind, mousebind, selected openbox theme, and many other things. And my config rely on keybind settings.
MoveResizeTo action that like it’s name let us move and resize window in specific location and size. It can be either represented by pixel or percent.
The configuration above will move our window to 34% from left and 2% from top of the screen, and will resize to 96% in height and 32% in width. However, it only works on unmaximized windows. To make it works on maximized windows, we must first unmaximize that window. It can be done if we add this action:
Add it above the
MoveResizeTo action. Thus, our configuration will looks like:
Don’t forget to bind keys or that configuration won’t be applicable. In my case, I bind it to
Now we can tile our window to center with 1/3 monitor width if we press
Ofcourse, we need to bind other keys like tile to left with 1/3 monitor width, etc, etc. Below is my current pseudo-tiling configuration. Add it beetween
<!-- gaps 2 windows -->
Need cheat sheet?
I’ll give you for free
|Super + Alt + Up||TIle window to upper half|
|Super + Alt + Down||Tile window to bottom half|
|Super + Alt + Right||Tile window to half right|
|Super + Alt + Left||Tile window to half left|
|Super + z||Tile window 1/3 to right|
|Super + x||Tile window 1/3 to middle|
|Super + c||Tile window 1/3 to left|
|Super + h||Tile window 1/4 to top right|
|Super + j||Tile window 1/4 to top left|
|Super + k||Tile window 1/4 to bottom right|
|Super + l||Tile window 1/4 to bottom left|
|Super + Shift + z||Tile window 1/6 to top right|
|Super + Shift + x||Tile window 1/6 to top middle|
|Super + Shift + c||Tile window 1/6 to top left|
|Super + Control + z||Tile window 1/6 to bottom right|
|Super + Control + x||Tile window 1/6 to bottom middle|
|Super + Control + c||Tile window 1/6 to bottom left|
It will respond right away after we press the shortcut.
Because we use percent, if we change our resolution or project our monitor to different monitor, the size and placement of the window won’t be awkward.
Margin changed when given different resolution
While using percent can make our window resizing fluid. It will break the grid margin.
With that limitation, Twily has made a script to tile windows into grid using wmctrl and xdotool in bash scripting. You can download it here. The advantages is that it will give you constant margin . You can easily change it from within the script. It will also works with other NETWM compilant window manager.
However, the default script has a disadvantage. The width and height of the monitor is hardcoded into the script. We don’t want that, right? We want it to follow the current resolution, so when go to portrait mode, the tiling will also working great.
You can add and change few lines of code to achieve that. First we get the current resolution with
xrandr, add code below after
if [ "$WNAME" == "Desktop" ]; then exit 3; fi line
RES=$(xrandr --query | grep ' connected' | grep -o '[0-9][0-9]*x[0-9][0-9]*[^ ]*' | sed -r 's/^[^0-9]*([0-9]+x[0-9]+).*$/\1/')
In my 1600x900 resolution, the
RES variable will return
1600x900, and if i use portrait mode it will return
900x1600. After that we need to change
H variable so it get the resolution correctly.
W=$(echo $RES | cut -d "x" -f 1)
Thats it! I know the execution time will drastically longer, in my case from 0.002 seconds into 0.240 seconds. But, hey, i’m using traditional harddisk in my machine. It shouldn’t be that long with modern machine that use SSD (wish i can buy it soon :D ). Right now, i’m only using grid method so i can bind other key to other task.
Thanks for reading!