Sane keyboard controls for resizing windows

I have never really used the Mod+r resizing mode and simply wanted to use a normal bind to adjust window size. The problem I have it seems to work on windows to right of workspace but is reversed on any windows on left side of screen.

Have these weird binds in my config which allows left windows to work correctly but again not on the right.

#Swap keyboard resizing controls for windows on the left and right sides of the screen
bindsym $mod+Ctrl+Left  [con_id="__focused__" ] resize shrink width 10 px or 10 ppt  
bindsym $mod+Ctrl+Right [con_id="__focused__" ] resize grow width 10 px or 10 ppt
#bindsym $mod+Up    [con_id="__focused__" workspace="^1"] resize shrink height 10 px or 10 ppt
#bindsym $mod+Down  [con_id="__focused__" workspace="^1"] resize grow height 10 px or 10 ppt

Am not about to reach for the mouse, any one have any ideas?

1 Like

There is a resize “mode” which might work better than the option you are using. Mine looks like this:

#
# Resizing containers:
#
mode "resize" {
    bindsym Left resize shrink width 10px
    bindsym Down resize grow height 10px
    bindsym Up resize shrink height 10px
    bindsym Right resize grow width 10px

    bindsym Return mode "default"
    bindsym Escape mode "default"
}
bindsym $mod+r mode "resize"

Meta+R starts resize mode, then you do your changes and hit Enter or Escape to get out of it.

They have something similar in the default i3 config here: https://github.com/i3/i3/blob/next/etc/config.keycodes

That works fine for left window but right window controls seem to be reversed…

It probably isn’t reversed it may just look like it due to tilling behaviour.
I have this setting.

bindsym $mod+Ctrl+Up resize shrink height 5 px
bindsym $mod+Ctrl+Down resize grow height 5 px
bindsym $mod+Ctrl+Left resize shrink width 5 px
bindsym $mod+Ctrl+Right resize grow width 5 px

The resizing moves right and bottom edge of the window to modify width and height.

Imagine that you have screen with resolution 100x100 (very tiny display :grinning:). 2 windows next to each other have both width 50 pixels and the separator between them is in the middle of the screen.

If you have left winow in focus and press $mod+Ctrl+right it will change the width ratio to 55:45 and the separator moves to right.

If instead you have right window selected and press the same $mod+Ctrl+right it will try to increase the rigth window to width 55, the right edge of the window wants to move to the right but there is the edge of the screen. So instead it forces the position of the window 5 pixels to the left then increases the width and shrinks left window. You should end with widnows with the width ratio 45:55.

You can also set the config to modify the window size with mouse, although it may not fit into the “keyboard only” workflow of i3wm.

# Use Mouse+$mod to drag/resize floating windows
floating_modifier $mod

$mod+left mouse click moves window and $mod+right mouse click resize the window.

Try the behaviour with 3 windows as well.

This may be a little overkill but for me this seems like a step in the right direction. On my keyboard layout I have the < > symbols so figured I would use them to test my theory. Of course they are , and .

Adding Shift means it will work for windows on right side of screen too. If I forget no big deal very rarely use more than two windows on a workspace but this may help my work flow.

# resize mode sucks making this work on left windows
bindsym $mod+comma  resize shrink width 10px
bindsym $mod+period resize grow   width 10px  

# resize mode sucks making this work on right windows
bindsym $mod+Shift+comma  resize grow   width 10px
bindsym $mod+Shift+period resize shrink width 10px

Do you ever use 3 or more windows next to each other? How do you expect to it will work in that case?

Three vertical windows simply means I need Shift to move the second and third window in a sane manor.