the best way to configure your dwm
Tags: suckless, dwm, patching
Published: 2021-06-21 14:03:25

hello everyone, dwm is the best window manager you can use it's fast and minimalism and this the best thing i love of [suckless philosophy](https://suckless.org/philosophy/) , in this post i'll show you how to configure your dwm, we will configure keybinds & color schema & some tasks can help you for make an awesome WM
for configure your dwm (or any suckless programs) you need to change somethings in **config.h**

first let's start with keybinds, dwm works with **ALT** key if you wan't to change it from **ALT** to **SUPER** key, change **config.h** from **#define MODKEY Mod1Mask** to **#define MODKEY Mod4Mask** for add/remove keybinds for dwm go to **keys** list from **config.h**

```c
static Key keys[] = {
	/* modifier                     key        function        argument */
	{ MODKEY,                       XK_d,      spawn,          {.v = dmenucmd } },
	{ MODKEY,	                XK_Return, spawn,          {.v = termcmd } },
    ..... etc ....
    ....
```
dwm default keys for kill programs is **SUPER + c** , i'll change it to **q**
```
keys[] =
... 
..
+ { MODKEY,             		XK_q,      killclient,     {0} },
...
```

if you wan't to add more keybinds add a varible with your command you wan't to run with your keybind for example i need to run **$ pamixer --allow-boost -i 10** for up the audio
```
static const char *audioup[] = { "pamixer --allow-boost -i 10",NULL };

// EXAMPLE
{ MODKEY,                       XK_{KEY},      spawn,          {.v = {COMMAND} } }
// REAL
{ MODKEY, 			XK_p,	   spawn,	   {.v = audioup}},

// SUPER + p = audioup command
```
take the idea and make your own keybinds or if you hate to configure your keybind from **C** code you can use [sxhkd](https://github.com/baskerville/sxhkd) with simple config file :)

***

for change the terminal from [ST](https://st.suckless.org/) to your fav terminal go to **config.h** and search for **termcmd[]** and change the value from **st** to **terminator** for example
***

for change the font of dwm go to your **config.h** file and search for **fonts[]** and change the value to your fav font name & size for example
```C
static const char *fonts[]          = { "monospace:size=13" };
```
for change your colorschema search for **static const char col_gray** and change what you wan't with color picker, or you can use [Pywal](https://github.com/dylanaraps/pywal) to generate colorschema with your wallpaper
**$ wal -i wallpaper.png**

and add this line **#include "/home/${your username}/.cache/wal/colors-wal-dwm.h"** for your **config.h** and remove this lines from **config.h**
```
static const char *colors[][3]      = {
	/*               fg         bg         border   */
	[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
	[SchemeSel]  = { col_gray4, col_cyan,  col_cyan  },
};

```
and remove **[SchemeUrg] =  { urg_fg,      urg_bg,    urg_border },** from **~/.cache/wal/colors-wal-dwm.h**, now your colorschema will generate with your wallpaper.png

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/00v4lspvuf1y5184na7r.png)


if you want to add auto start function for your dwm you can use [cool autostart](https://dwm.suckless.org/patches/cool_autostart/) patch , after patch with **$ git apply cool-autostart.diff** you need to add this line for **config.h** with your commands

```
static const char *const autostart[] = {
	"compton", NULL,
    "sxhkd",NULL,
    "wal -R",NULL,
	NULL
};
```



after that run **$ sudo make clean install** and enjoy :)