This page looks best with JavaScript enabled

Tiling WM (i3)

 ·   ·  โ˜• 4 min read · ๐Ÿ‘€... views

What is a window manager

i3 is a tiling window manager, which

Stacking WM

  • mostly mouse driven, slow
  • windows overlap with each other, space inefficient

Tiling WM

  • automatically layout windows like tiles, high space efficiency
  • mostly keyboard driven, fast
  • multiple layout mode: tabbed, stacked, horizontal/vertical split, float

Understand Container & Tree

In i3, windows are stored as leaf nodes of a tree, each workspace has a tree. Non leaf nodes of the tree are called containers, whose children are other containers or windows.

Attributes of a container

layout mode

i3 has layout mode like:

  • split (horizontally or vertically)
  • tabbed
  • stacked

Why we need a layout mode attribute, to give you an example, imagine we have a tree structure like this, managing 3 windows.

Figure 1: tree of ambiguous layout

Figure 1: tree of ambiguous layout

Since we do not know how to place windows inside a container, figure 1 may represents windows like figure 2, or figure 3 or something else. Therefore, containers must have a layout mode.

Figure 2: possible window status 01

Figure 2: possible window status 01

Figure 3: possible window status 02

Figure 3: possible window status 02

To only represents windows in figure 2, we add layout attribute to each container, as in figure 4.

Figure 4: tree of unambiguous layout

Figure 4: tree of unambiguous layout

percentage of width or height in split direction

To control the width or height of windows, we need to add percentage of width or height in split direction. as in figure 5

Figure 5: tree with container percentage

Figure 5: tree with container percentage

Practice

To better understand the tree structure, we can put our windows or containers inside a tabbed/stacked container, and get the tree structure through the container title.

Here’s how you can get the container title:

  1. switch to an empty workspace: $Mod+3.
  2. toggle root container layout mode as split(horizontal or vertical): $Mod+e (usually we do not set root container layout mode as stacked or tabbed)
  3. open the first window in this workspace: $Mod+ENTER (opens my st terminal)
  4. set container (of this window) layout as tabbed or stacked: $Mod+w/s
  5. create a new vertical/horizontal split container: $Mod+v/V
    • when container of the focused node(container or window) contains only a single node, and the container layout is set to split, $Mod+v/V only changes the split direction
    • when container of the focused node contains more than one node, or container layout is set to tabbed/stacked, $Mod+v/V will create a new vertical/horizontal split container encapsulating current focused node
  6. now you can see a container title showing V[st] (V means horizontal split layout), create more containers or change container layout to see the title change: open one more st window with $Mod+ENTER changes the title to V[st st]

some of my i3 shortcuts

Here’s a snippet of my i3 configuration. Complete configuration is stored at my .dotfiles repository.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# some configs from my ~/.config/i3/config
set $mod Mod4

set $up k
set $down j
set $left h
set $right l

# change focus
bindsym $mod+$left focus left
bindsym $mod+$down focus down
bindsym $mod+$up focus up
bindsym $mod+$right focus right

# move focused window
bindsym $mod+Shift+$left move left
bindsym $mod+Shift+$down move down
bindsym $mod+Shift+$up move up
bindsym $mod+Shift+$right move right

# split in horizontal orientation
bindsym $mod+Shift+v split h

# split in vertical orientation
bindsym $mod+v split v

# enter fullscreen mode for the focused container
bindsym $mod+f fullscreen toggle

# change container layout (stacked, tabbed, toggle split)
bindsym $mod+s layout stacking
bindsym $mod+w layout tabbed
bindsym $mod+e layout toggle split

# toggle tiling / floating
bindsym $mod+Shift+space floating toggle

# change focus between tiling / floating windows
bindsym $mod+space focus mode_toggle

# focus the parent container
bindsym $mod+p focus parent

# focus the child container
bindsym $mod+c focus child

# resize window (you can also use the mouse for that)
set $resize_step 5

bindsym $mod+y resize shrink width $resize_step px or $resize_step ppt
bindsym $mod+i resize grow height $resize_step px or $resize_step ppt
bindsym $mod+u resize shrink height $resize_step px or $resize_step ppt
bindsym $mod+o resize grow width $resize_step px or $resize_step ppt
Mod-h/j/k/l
change focus to the left/upper/lower/right window
Mod-S-h/j/k/l
move focused window/container
Mod-y/u/i/o
change size of focused window/container
Mod-v/V
add a container for current window, set layout to vertical/horizontal split
Mod-e/w/s
set layout of container of focused window to split(toggles between splith, splitv)/tabbed/stacked
Mod-p
focus parent
Mod-c
focus child

References

Share on