Search code examples
i3

i3: rotate container layout back and forth


i3wm offers 4 styles for orgnizing child contaniner:

  • Vertical split
  • Horizontal split
  • Stacked
  • Tabbed

Instead of having one key shortcut for each of them, I would like to rotate through them using only one key.

Reading the documentation I found it is now possible to cycle through all available layouts:

layout toggle all

But this cycles only in one direction.

I would like to be able to cycle in both directions. It is often the case I do it very fast and I pass by the layout I want. In this case I would be able to go back with just only one keystroke instead of having to rotate all over again.


Solution

  • It is possible to list all the layouts explicitely and have an other command with the same layouts but in reverse order:

    Example:

    bindsym $mod+e layout toggle splith tabbed stacked splitv
    bindsym $mod+Shift+e layout toggle splitv stacked tabbed splith 
    

    This simulates the desired behaviour, as every time the command is executed, the layout specified after the currently active one will be applied.

    Reference: https://i3wm.org/docs/userguide.html#manipulating_layout