Spectrwm – minor annoyance solved

Last Updated on

My favourite window manager is Spectrwm but with its default setting I get a minor annoyance in relation to window focusing.

Suppose you have Window A in Main and Window B in Stack and the focus is on Window A. You now swap these two windows with Mod+Return, so that Window A is in the Stack and Window B is in Main. With the default setting the focus is still on Window A but I usually want it to be on Window B, in Main.

Of course, I can easily achieve this with Mod+m, but I find it irritating to have to do this each time I switch windows, which I do very frequently. In dwm the problem doesn’t arise and I was seriously thinking of changing to dwm for this reason. But Spectrwm has so many features I like that this wasn’t really an option.

The solution, as so often, was RTFM.  The man page says that setting “focus mode” to “follow” does this:

Set window focus on all cursor border crossings,
including workspace switches and changes to layout.

This gives me the behaviour I want. The cursor is normally in the window I’m working in (Window A initially in this case). When I swap the windows the cursor is still Main, which now contains Window B, and the focus follows it. Simple, really.

However, this creates a problem. Mod+Space cycles between three different layouts one of which is  layout_max, but when I access this the display flickers. As I don’t need layout_max (I can use Mod+e for this) I unbind Mod+Space to prevent that layout being accessed accidentally;  I bind Mod+v for vertical layout and Mod+z for horizontal layout. Here are the relevant entries in the configuration file.

bind[] = Mod+space  # unbind mod + Space
bind[layout_vertical] = Mod+v
bind[layout_horizontal] = Mod+z

Note: For this to work, the pointer must be in the window you want the focus to be in (on the left of the sceeen, i.e. in Main). Just occasionally I still get a flicker, e.g. if starting Firefox from dmenu); to stop this, use Mod+q.

 

Leave a Reply

Your email address will not be published. Required fields are marked *

Anti-Spam Quiz: