Skip to content
Robin te Hofstee — Personal Blog
➜~neofetch

robin@blog

Name
Robin te Hofstee
Role
Full-stack developer, sysadmin & technical writer
Focus
homelab · Linux · self-hosting · Next.js
Posts
61 · latest Nov 30, 2026
Host
blog.robintehofstee.com
Links
github · rss · portfolio
➜curlblog.robintehofstee.com
➜~cat/blog/how-to-configure-and-master-dwm-key-bindings-in-linux.mdx
←cd ~

How to Configure and Master `dwm` Key Bindings in Linux

Nov 30, 20263 minLinuxdwmkeybindings

dwm (dynamic window manager) relies on keyboard-driven window management and compile-time configuration in C. Instead of editing a runtime config file and reloading it on the fly, you define key bindings inside a C header file and recompile dwm whenever you make changes.

1. Essential Default Key Bindings#

In a vanilla dwm setup, MODKEY defaults to Mod1Mask (Alt). These core shortcuts cover daily navigation and window control:

Key BindingAction
Mod + Shift + ReturnLaunch a terminal (st by default)
Mod + pOpen dmenu to launch applications
Mod + j / Mod + kFocus next / previous window in the current stack
Mod + h / Mod + lDecrease / increase master area width
Mod + i / Mod + dIncrease / decrease number of windows in the master area
Mod + ReturnZoom/promote focused window to (or from) the master area
Mod + Shift + cClose (kill) the focused window
Mod + bToggle the top status bar on or off
Mod + Shift + qQuit dwm cleanly

2. Layouts and Floating Windows#

dwm ships with three built-in layouts: tiled ([]=), floating (><>), and monocle ([M]).

  • Switch to tiled layout: Mod + t
  • Switch to floating layout: Mod + f
  • Switch to monocle (fullscreen-like stack) layout: Mod + m
  • Toggle previous layout: Mod + Space
  • Toggle floating state on focused window: Mod + Shift + Space
  • Move or resize floating windows with the mouse: Hold Mod + Left Click to drag, or Mod + Right Click to resize.

3. Tags and Multi-Monitor Navigation#

Rather than fixed virtual desktops, dwm uses tags (1 through 9 by default):

  • View tag N: Mod + [1-9]
  • Move focused window to tag N: Mod + Shift + [1-9]
  • Toggle viewing tag N alongside current tags: Mod + Ctrl + [1-9]
  • Toggle tag N on focused window: Mod + Ctrl + Shift + [1-9]
  • View windows from all tags: Mod + 0
  • Focus previous / next monitor: Mod + , / Mod + .
  • Send focused window to previous / next monitor: Mod + Shift + , / Mod + Shift + .

4. How Key Bindings Work in config.h#

Open your dwm source directory and copy config.def.h to config.h if you have not already done so. Keeping config.def.h untouched makes applying patches much cleaner later.

Inside config.h, bindings are defined in the static const Key keys[] array using this structure:

c
/* modifier                     key        function        argument */
{ MODKEY,                       XK_p,      spawn,          {.v = dmenucmd } },
{ MODKEY|ShiftMask,             XK_Return, spawn,          {.v = termcmd } },
{ MODKEY,                       XK_b,      togglebar,      {0} },
{ MODKEY,                       XK_j,      focusstack,     {.i = +1 } },
{ MODKEY,                       XK_k,      focusstack,     {.i = -1 } },
Share