Switching window focus ($mod+Up
/ $mod+Right
/ $mod+Down
/ $mod+Left
) in i3 cycles through all windows on a workspace, meaning when you hit one edge of the screen, it will start again on the other side.
I was looking for a way to disable that, but was unable to find a way to change this via configuration. Therefore I have created the following script.
Place i3-focus-nowrap.sh
somewhere within your path (eg /usr/local/bin
) or use an absolute reference in the keybindings below.
And replace the keybindings in your .i3 config (eg ~/.i3/config
)
so change:
# change focus
bindsym $mod+j focus left
bindsym $mod+k focus down
bindsym $mod+l focus up
bindsym $mod+odiaeresis focus right
# alternatively, you can use the cursor keys:
bindsym $mod+Left focus left
bindsym $mod+Down focus down
bindsym $mod+Up focus up
bindsym $mod+Right focus right
to:
# change focus
bindsym $mod+j exec i3-focus-nowrap.sh left
bindsym $mod+k exec i3-focus-nowrap.sh down
bindsym $mod+l exec i3-focus-nowrap.sh up
bindsym $mod+odiaeresis exec i3-focus-nowrap.sh right
# alternatively, you can use the cursor keys:
bindsym $mod+Left exec i3-focus-nowrap.sh left
bindsym $mod+Down exec i3-focus-nowrap.sh down
bindsym $mod+Up exec i3-focus-nowrap.sh up
bindsym $mod+Right exec i3-focus-nowrap.sh right
My configuration has 6px gaps around windows + 19px status bar at the bottom, if you have a different configuration adjust gapWidth
in i3-focus-nowrap.sh
- jq (to parse json)
This scripts are obsolete since i3wm version 4.15:
See: