i3 window manager - multi-monitor workspaces

By default, the i3 tiling window manager allows switching workspaces on each monitor separately. We can achieve switching the workspace at all monitors at once, so that we will have something like multi-monitor workspaces instead.

(1) Define monitor names. These can be easily obtained by running the xrandr command without any arguments.

set $monitorA "HDMI-0"
set $monitorB "DVI-D-0"

(2) Set workspace names. We will have 4 “A” workspaces for the first monitor and 4 “B” workspaces for the second monitor. This will allow us to have 4 “multi-monitor” workspaces.

set $ws1A "1A"
set $ws2A "2A"
set $ws3A "3A"
set $ws4A "4A"
set $ws1B "1B"
set $ws2B "2B"
set $ws3B "3B"
set $ws4B "4B"

(3) Bind workspaces to specific monitors, so that the “A” workspaces will be always opened on the first monitor and the “B” workspaces on the second one.

workspace $ws1A output $monitorA
workspace $ws2A output $monitorA
workspace $ws3A output $monitorA
workspace $ws4A output $monitorA
workspace $ws1B output $monitorB
workspace $ws2B output $monitorB
workspace $ws3B output $monitorB
workspace $ws4B output $monitorB

(4) Define workspaces switching, so that both workspaces (for both monitors) will be switched at once. Note that the “workspace per monitor” logic of i3 is still preserved - here we only create the illusion of multi-monitor workspaces by actually switching the workspaces on both monitors at once.

bindsym $mod+1 workspace $ws1B; workspace $ws1A
bindsym $mod+2 workspace $ws2B; workspace $ws2A
bindsym $mod+3 workspace $ws3B; workspace $ws3A
bindsym $mod+4 workspace $ws4B; workspace $ws4A

There is a disadvantage that after switching, the workspace “A” will always be the active one (even if workspace “B” was active previously). This is because we actually do 2 separate actions when the switching key is pressed - switch to “B” workspace and then immediately to the corresponding “A” workspace. It can be made the other way around if preferred - each of the 4 lines could switch to “A” workspace first and then subsequently to the “B” workspace, leaving the “B” workspace as the active one.

(5) Define windows moving to specific workspaces. Here, a window will move always to the “A” workspace, even if it was on some “B” workspace previously. This is a slight disadvantage, too.

bindsym $mod+Shift+1 move container to workspace number $ws1A
bindsym $mod+Shift+2 move container to workspace number $ws2A
bindsym $mod+Shift+3 move container to workspace number $ws3A
bindsym $mod+Shift+4 move container to workspace number $ws4A

(6) Note that if you have more monitors or want more workspaces, you can edit the configuration accordingly by copying the relevant parts more times.

Written on January 23, 2022