The i3 FAQ has migrated to All content here is read-only.
Ask Your Question

conditional window splits

asked 2014-11-18 18:30:25 +0000

Is it possible in stacking layout mode to have a window split conditionally on the current dimensions?

For example, if the height is greater than the width, I'd like the tile to be split vertically. If the width is greater than the height, split horizontally.

Rationale: There is a small, but noticable cognitive load when manually prefixing my action with mod+v, mod+h.

If this is not currently possible in i3, would it be worth filing a ticket to add a conditional tiling policy indicator to .i3/config?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2014-11-18 21:15:44 +0000

Adaephon gravatar image

With xdotool and a bit of awk and shell magic that is no problem:

Save this script as

xdotool getactivewindow getwindowgeometry | awk '/Geometry/{split($2, dim, "x"); if (dim[1] > dim[2]) {exit 1}}' && i3-msg split vertical || i3-msg split horizontal

and then put a shortcut to it in your ~/.i3/config

bindsym $mod+s exec --no-startup-id /path/to/

This retrieves the current windows dimensions, checks if it is wider than high and runs i3-msg split vertical in that case, else it runs i3-msg split horizontal.

edit flag offensive delete link more


Awesome hack! Seeing what you did there gives me some other ideas about using xdotool.

Jeff Bauer gravatar imageJeff Bauer ( 2014-11-18 21:28:50 +0000 )edit

Question Tools


Asked: 2014-11-18 18:30:25 +0000

Seen: 181 times

Last updated: Nov 18 '14