Skip to content

masterstacker

bakkeby edited this page Jul 1, 2024 · 2 revisions

The master stacker utilities provides comprehensive ways of managing the client stack.

It is building on the ideas of the popular stacker patch for dwm which is considered by many to be the ultimate way to control windows using keyboard shortcuts.

The main difference between the dwm patch and this implementation is that in the stacker patch floating and tiled clients are selected based on the client stack index, whereas in this patch client selection is restricted to tiled clients only.

Additionally the master stacker makes the distinction between master and stack areas.

The keybindings are defined in the STACKKEYS macro as the same keys are used with different modifiers to access different functionality.

#define STACKKEYS(MOD,ACTION) \
	{ MOD, XK_j,                ACTION, {.i = INC(+1) } }, \
	{ MOD, XK_k,                ACTION, {.i = INC(-1) } }, \
	{ MOD, XK_semicolon,        ACTION, {.i = PREVSEL } }, \
	{ MOD, XK_y,                ACTION, {.i = MASTER(1) } }, \
	{ MOD, XK_u,                ACTION, {.i = MASTER(2) } }, \
	{ MOD, XK_n,                ACTION, {.i = STACK(1) } }, \
	{ MOD, XK_o,                ACTION, {.i = STACK(2) } }, \
	{ MOD, XK_g,                ACTION, {.i = STACK(3) } }, \
	{ MOD, XK_slash,            ACTION, {.i = LASTTILED } },

This macro can be expanded to hold shortcuts for more clients as needed.

Disclaimer: the keybinding arrangement above is a bad example trying to fit in along with the keybindings that already exists in a bare dwm.

It is generally expected that the user reshuffles existing keybindings to give room to better take advantage of the master stacker functionality.

An example one-handed setup that I personally use:

 +  -
 m1 s1 s2 prev
 m2 s3 s4 last
    s5 s6

Here is an explanation for the values passed to functions.

Argument Description
INC(+1) Next client relative to the selected client
INC(-1) Previous client relative to the selected client
PREVSEL The previously selected client
MASTER(n) The nth client in the master area
STACK(n) The nth client in the stack area
1 The first client in the stack (often the master client)
2 The second client in the stack (often the first stack client)
3 The third client in the stack (often the second stack client)
LASTTILED The last client in the stack (alternatively -1)

1, 2 and 3 above refers to the nth tiled client similarly to how the original stacker works. Note that in this patch the nth client starts at 1.

The nth client will also reduce if there are less tiled clients than the desired number. E.g. if there are only 2 tiled clients then focusing on 3 will change focus to the last tiled client (2).

LASTTILED refers to the last tiled client in the stack.

PREVSEL refers to the previously visible selected client on the current monitor.

The STACKKEYS macro is used in the keys array.

	STACKKEYS(MODKEY,             stackfocus) // focus on the nth client in the stack
	STACKKEYS(MODKEY|ControlMask, stackpush)  // move the currently focused client to the nth place in the stack
	STACKKEYS(MODKEY|ShiftMask,   stackswap)  // swap the currently focused client with the nth client in the stack

Here is a breakdown of the three functions.

Function Description
stackfocus Focus on the nth client
stackpush Move the current client above the nth position in the stack
stackswap Swap the current client with the nth client (like zoomswap)

The stackpush is there for people that are more accustomed to the way the original stacker patch works. Some people may prefer the stackswap method of exchanging clients.

When swapping clients the client that has focus will keep focus, unless one of the two clients is in the master area in which case the master client will get focus.


The general idea is that MOD+y and MOD+u focuses on the first and second master client respectively, while MOD+n focuses on the first stack client and so on.

The benefit of this is that the stack clients are always accessible using the same keybindings regardless of how windows are in the master area.

More so doing MOD+m when there is only a single master client will select that master client rather than the first client in the stack area. This is due to how the nth client will reduce within the respective tiled area.

If the distinction between the master and stack areas is undesired then one can refer to the nth tiled client directly similarly to how it works with the stacker patch for dwm.

For example:

#define STACKKEYS(MOD,ACTION) \
	{ MOD, XK_j,                ACTION, {.i = INC(+1) } }, \
	{ MOD, XK_k,                ACTION, {.i = INC(-1) } }, \
	{ MOD, XK_semicolon,        ACTION, {.i = PREVSEL } }, \
	{ MOD, XK_y,                ACTION, {.i = 1 } }, \
	{ MOD, XK_u,                ACTION, {.i = 2 } }, \
	{ MOD, XK_n,                ACTION, {.i = 3 } }, \
	{ MOD, XK_o,                ACTION, {.i = 4 } }, \
	{ MOD, XK_g,                ACTION, {.i = 5 } }, \
	{ MOD, XK_slash,            ACTION, {.i = LASTTILED } },

Download

Clone this wiki locally