Can dwm handle a keybinding sequence pressed one after another?

144 views Asked by At

Can the dwm (https://dwm.suckless.org/) window manager natively handle a keybinding sequence pressed one after another (as opposed to pressing them together simultaneously) like in spacemacs? If not, is it possible to make dwm work with something like sxhkd (https://github.com/baskerville/sxhkd)?

In i3 (https://i3wm.org/), I use

set $mod Mod4
bindsym $mod+w mode "workspace"
mode "workspace" {
    bindsym j workspace next_on_output
    bindsym k workspace prev_on_output
    bindsym Escape mode "default"
}

to get into a "workspace" mode by pressing Mod4+w simultaneously and then I could just use j or k to navigate the workspaces until I press Escape. How can I achieve the same behavior on dwm?

1

There are 1 answers

0
skink On BEST ANSWER

You can achieve that behaviour by applying the Keychain and Cyclelayouts patches. The configuration looks like:

static Key keys[] = {
  /* ... */
  { MODKEY, XK_w, XK_j,      cyclelayout, {.i = -1 } },
  { MODKEY, XK_w, XK_k,      cyclelayout, {.i = +1 } },
  { MODKEY, XK_w, XK_Escape, setlayout,   {0} },
};

The Keychain patch, if you wish, can be replaced with the Keychord patch. The configuration then looks just a bit different:

static Keychord keychords[] = {
  /* ... */
  {2, {{MODKEY, XK_w}, {0, XK_j}},      cyclelayout, {.i = -1 } },
  {2, {{MODKEY, XK_w}, {0, XK_k}},      cyclelayout, {.i = +1 } },
  {2, {{MODKEY, XK_w}, {0, XK_Escape}}, setlayout,   {0} },
};