Last Updated on
One of the commonest things I do in Spectrwm is swap two windows (Main to Stack or vice versa). This is done instantly with Mod+Return. But a minor annoyance is that the focus doesn’t follow the swap.
Suppose you have two windows open, A in Main and B in Stack, and the focus is on A. After the swap the focus is still on A but this is now in the Stack. I usually want it to be in Main, which now contains B. I can achieve this with Mod+m, which alternates the focus back and forth between the two windows. This is OK but can become annoying if I do it a lot since it’s easy to miss-type the m.
For a time I solved this by setting the pointer focus to “follow” instead of the default, but this wasn’t ideal; it required me to keep the pointer always in the left side of the screen and occasionally the display got messed up and needed fixing with Mod+q.
The solution I’ve adopted now is to remap Mod+Space (quick and easy to type) to give me focus_main. By default Mod+Space cycles between vertical, horizontal, and full-screen layouts, but I hardly ever need to do this. I’ve mapped Mod+v and Mod+z to give me vertical and horizontal layouts in case I do need to change them; for full-screen I use Mod+e.
Here are the entries in .spectrwm.conf.
bind[focus_main] = Mod+space
bind[layout_vertical] = Mod+v
bind[layout_horizontal] = Mod+z