master config.h
ohmu  ·  2026-10-18
  1/* Taken from https://github.com/djpohly/dwl/issues/466 */
  2#define COLOR(hex)    { ((hex >> 24) & 0xFF) / 255.0f, \
  3                        ((hex >> 16) & 0xFF) / 255.0f, \
  4                        ((hex >> 8) & 0xFF) / 255.0f, \
  5                        (hex & 0xFF) / 255.0f }
  6/* appearance */
  7static const int tabletmaptosurface                = 1;  /* map tablet input to surface(1) or monitor(0) */
  8static const int sloppyfocus                       = 1;  /* focus follows mouse */
  9static const int bypass_surface_visibility         = 0;  /* 1 means idle inhibitors will disable idle tracking even if it's surface isn't visible  */
 10
 11#define ZOOMMIN 0.05
 12#define ZOOMMAX 3
 13#define animatezoom 1
 14#define zoomduration 0.33
 15#define zoombezier "0.22,1.0,0.36,1.0"
 16#define movecanvasmouse_multiplier_is_affected_by_zoom 1
 17#define ZOOM_IN_TOWARDS_CURSOR 1
 18#define ZOOM_OUT_TOWARDS_CURSOR 0
 19
 20#define SPAWNREGION_STYLE 2 /* 0 = None
 21                               1 = Full rectangle.
 22                               2 = outline
 23                            */
 24
 25/* gaps */
 26static const int enablegaps                        = 1;  /* 1 means gaps are enabled */
 27static const int smartgaps                         = 0;  /* 1 means no outer gap when there is only one window */
 28static const int monoclegaps                       = 0;  /* 1 means outer gaps in monocle layout */
 29static const unsigned int gappih                   = 10; /* horizontal inner gap between windows */
 30static const unsigned int gappiv                   = 10; /* vertical inner gap between windows */
 31static const unsigned int gappoh                   = 10; /* horizontal outer gap between windows and screen edge */
 32static const unsigned int gappov                   = 10; /* vertical outer gap between windows and screen edge */
 33
 34/* colors */
 35static const float rootcolor[]                     = COLOR(0x22222267); /* Background color, only visible without any wallpaper setter */
 36
 37/* inner border */
 38static const unsigned int innerborderpx = 4;  /* inner border pixel width */
 39
 40static const float focused_inner_border_color[]    = COLOR(0xFDD9C6ff);
 41static const float urgent_inner_border_color[]     = COLOR(0xFDD9C6ff);
 42static const float unfocused_inner_border_color[]  = COLOR(0x7B565600);
 43
 44/* outer border */
 45static const unsigned int outerborderpx = 6;  /* outer border pixel width */
 46
 47static const float focused_outer_border_color[]    = COLOR(0x0a0100ff);
 48static const float urgent_outer_border_color[]     = COLOR(0x0a0100ff);
 49static const float unfocused_outer_border_color[]  = COLOR(0x1e1c1c00);
 50
 51#define SPAWNREGION_COLOR COLOR(0xFDD9C667)
 52
 53static const unsigned int spawnregion_innerborderpx  = 3;  /* spawnregion inner border pixel width */
 54static const unsigned int spawnregion_outerborderpx  = 7;  /* spawnregion outer border pixel width */
 55static const float spawnregion_inner_border_color[]  = COLOR(0xC9B8B6ff);
 56static const float spawnregion_outer_border_color[]  = COLOR(0x430a03ff);
 57
 58/* This conforms to the xdg-protocol. Set the alpha to zero to restore the old behavior */
 59static const float fullscreen_bg[]         = {0.0f, 0.0f, 0.0f, 1.0f}; /* You can also use glsl colors */
 60/* Pen active area: value 0.0 => 1.0         { x,    y,    width, height } */
 61static const double tablet_area[4] 		   = { 0.4,  0.4,  0.4,   0.4 };
 62
 63/* tagging - TAGCOUNT must be no greater than 31 */
 64#define TAGCOUNT (9)
 65
 66/* logging */
 67static int log_level = WLR_ERROR;
 68
 69
 70
 71static const Rule rules[] = {
 72	/* app_id             title       tags mask     isfloating   monitor */
 73	{ "Gimp_EXAMPLE",     NULL,       0,            1,           -1 }, /* Start on currently visible tags floating, not tiled */
 74	{ "firefox_EXAMPLE",  NULL,       1 << 8,       0,           -1 }, /* Start on ONLY tag "9" */
 75    /* default/example rule: can be changed but cannot be eliminated; at least one rule must exist */
 76};
 77
 78#define CENTER_NEW_WINDOWS 1
 79
 80/* layout(s) */
 81static const Layout layouts[] = {
 82	/* symbol     arrange function */
 83  { "><>",      NULL },    /* no layout function means floating behavior */
 84	{ "[]=",      tile },
 85	{ "[M]",      monocle },
 86};
 87
 88/* monitors */
 89/* (x=-1, y=-1) is reserved as an "autoconfigure" monitor position indicator
 90 * WARNING: negative values other than (-1, -1) cause problems with Xwayland clients due to
 91 * https://gitlab.freedesktop.org/xorg/xserver/-/issues/899 */
 92static const MonitorRule monrules[] = {
 93   /*    name  mfact nmaster  scale  layout       rotate/reflect                x   y      resx resy         rate mode   adaptive */
 94   /*
 95	* mode lets the user decide how dwl should implement the modes:
 96	* -1 sets a custom mode following the user's choice
 97	* All other numbers set the mode at the index n; 0 is the standard mode; see wlr-randr
 98	*/
 99  { "HDMI-A-1", 0.55f, 1, 1, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1, 0, 0, 180.003006f, 1, 0 },
100 	/* default monitor rule: can be changed but cannot be eliminated; at least one monitor rule must exist */
101};
102
103/* keyboard */
104static const struct xkb_rule_names xkb_rules = {
105	/* can specify fields: rules, model, layout, variant, options */
106	/* example:
107	.options = "ctrl:nocaps",
108	*/
109	.options = NULL,
110};
111
112static const int repeat_rate = 40;
113static const int repeat_delay = 250;
114
115/* Trackpad */
116static const int tap_to_click = 1;
117static const int tap_and_drag = 1;
118static const int drag_lock = 1;
119static const int natural_scrolling = 0;
120static const int disable_while_typing = 1;
121static const int left_handed = 0;
122static const int middle_button_emulation = 0;
123/* You can choose between:
124LIBINPUT_CONFIG_SCROLL_NO_SCROLL
125LIBINPUT_CONFIG_SCROLL_2FG
126LIBINPUT_CONFIG_SCROLL_EDGE
127LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN
128*/
129static const enum libinput_config_scroll_method scroll_method = LIBINPUT_CONFIG_SCROLL_2FG;
130
131/* You can choose between:
132LIBINPUT_CONFIG_CLICK_METHOD_NONE
133LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS
134LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER
135*/
136static const enum libinput_config_click_method click_method = LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS;
137
138/* You can choose between:
139LIBINPUT_CONFIG_SEND_EVENTS_ENABLED
140LIBINPUT_CONFIG_SEND_EVENTS_DISABLED
141LIBINPUT_CONFIG_SEND_EVENTS_DISABLED_ON_EXTERNAL_MOUSE
142*/
143static const uint32_t send_events_mode = LIBINPUT_CONFIG_SEND_EVENTS_ENABLED;
144
145/* You can choose between:
146LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT
147LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE
148*/
149static const enum libinput_config_accel_profile accel_profile = LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE;
150static const double accel_speed = -1.0;
151
152/* You can choose between:
153LIBINPUT_CONFIG_TAP_MAP_LRM -- 1/2/3 finger tap maps to left/right/middle
154LIBINPUT_CONFIG_TAP_MAP_LMR -- 1/2/3 finger tap maps to left/middle/right
155*/
156static const enum libinput_config_tap_button_map button_map = LIBINPUT_CONFIG_TAP_MAP_LRM;
157
158/* If you want to use the windows key for MODKEY, use WLR_MODIFIER_LOGO */
159#define MODKEY WLR_MODIFIER_LOGO
160#define ALT_MODKEY WLR_MODIFIER_ALT
161
162#define TAGKEYS(KEY,SKEY,TAG) \
163	{ MODKEY,                    KEY,            view,            {.ui = 1 << TAG} }, \
164	{ MODKEY|WLR_MODIFIER_CTRL,  KEY,            toggleview,      {.ui = 1 << TAG} }, \
165	{ MODKEY|WLR_MODIFIER_SHIFT, SKEY,           tag,             {.ui = 1 << TAG} }, \
166	{ MODKEY|WLR_MODIFIER_CTRL|WLR_MODIFIER_SHIFT,SKEY,toggletag, {.ui = 1 << TAG} }
167
168/* helper for spawning shell commands in the pre dwm-5.0 fashion */
169#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
170
171/* commands */
172static const char *termcmd[] = { "foot", NULL };
173static const char *menucmd[] = { "wmenu_run", NULL };
174
175static const Key keys[] = {
176	/* Note that Shift changes certain key codes: 2 -> at, etc. */
177	/* modifier                  key                  function          argument */
178	{ MODKEY,                    XKB_KEY_p,           spawn,            {.v = menucmd} },
179	{ MODKEY,                    XKB_KEY_Return,      spawn,            {.v = termcmd} },
180	{ MODKEY,                    XKB_KEY_j,           focusstack,       {.i = +1} },
181	{ MODKEY,                    XKB_KEY_k,           focusstack,       {.i = -1} },
182	{ MODKEY,                    XKB_KEY_i,           incnmaster,       {.i = +1} },
183	{ MODKEY,                    XKB_KEY_d,           incnmaster,       {.i = -1} },
184	{ MODKEY,                    XKB_KEY_h,           setmfact,         {.f = -0.05f} },
185	{ MODKEY,                    XKB_KEY_l,           setmfact,         {.f = +0.05f} },
186	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return,      swapmaster,       {0} },
187	{ MODKEY,                    XKB_KEY_Tab,         view,             {0} },
188	{ MODKEY,                    XKB_KEY_c,           killclient,       {0} },
189	{ MODKEY,                    XKB_KEY_t,           setlayout,        {.v = &layouts[1]} },
190	{ MODKEY,                    XKB_KEY_f,           setlayout,        {.v = &layouts[0]} },
191	{ MODKEY,                    XKB_KEY_m,           setlayout,        {.v = &layouts[2]} },
192	{ MODKEY,                    XKB_KEY_space,       setlayout,        {0} },
193	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space,       togglefloating,   {0} },
194	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_f,           togglefullscreen, {0} },
195	{ MODKEY,                    XKB_KEY_0,           view,             {.ui = ~0} },
196	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_parenright,  tag,              {.ui = ~0} },
197	{ MODKEY,                    XKB_KEY_comma,       focusmon,         {.i = WLR_DIRECTION_LEFT} },
198	{ MODKEY,                    XKB_KEY_period,      focusmon,         {.i = WLR_DIRECTION_RIGHT} },
199	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_less,        tagmon,           {.i = WLR_DIRECTION_LEFT} },
200	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_greater,     tagmon,           {.i = WLR_DIRECTION_RIGHT} },
201	TAGKEYS(          XKB_KEY_1, XKB_KEY_exclam,                        0),
202	TAGKEYS(          XKB_KEY_2, XKB_KEY_at,                            1),
203	TAGKEYS(          XKB_KEY_3, XKB_KEY_numbersign,                    2),
204	TAGKEYS(          XKB_KEY_4, XKB_KEY_dollar,                        3),
205	TAGKEYS(          XKB_KEY_5, XKB_KEY_percent,                       4),
206	TAGKEYS(          XKB_KEY_6, XKB_KEY_asciicircum,                   5),
207	TAGKEYS(          XKB_KEY_7, XKB_KEY_ampersand,                     6),
208	TAGKEYS(          XKB_KEY_8, XKB_KEY_asterisk,                      7),
209	TAGKEYS(          XKB_KEY_9, XKB_KEY_parenleft,                     8),
210	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_q,           quit,             {0} },
211
212	/* infinite_canvas */
213	{ MODKEY,                    XKB_KEY_r,            homecanvas,       {0} },
214	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Left,         movecanvas,       {.i = 0} },
215	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Right,        movecanvas,       {.i = 1} },
216	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Up,           movecanvas,       {.i = 2} },
217	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Down,         movecanvas,       {.i = 3} },
218	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_d,            centerwindow,     {0} },
219	/* infinite_canvas_end */
220	{ MODKEY|WLR_MODIFIER_LOGO,  XKB_KEY_h,          incgaps,       {.i = +1 } },
221	{ MODKEY|WLR_MODIFIER_LOGO,  XKB_KEY_l,          incgaps,       {.i = -1 } },
222	{ MODKEY|WLR_MODIFIER_LOGO|WLR_MODIFIER_SHIFT,   XKB_KEY_H,      incogaps,      {.i = +1 } },
223	{ MODKEY|WLR_MODIFIER_LOGO|WLR_MODIFIER_SHIFT,   XKB_KEY_L,      incogaps,      {.i = -1 } },
224	{ MODKEY|WLR_MODIFIER_LOGO|WLR_MODIFIER_CTRL,    XKB_KEY_h,      incigaps,      {.i = +1 } },
225	{ MODKEY|WLR_MODIFIER_LOGO|WLR_MODIFIER_CTRL,    XKB_KEY_l,      incigaps,      {.i = -1 } },
226	{ MODKEY|WLR_MODIFIER_LOGO,  XKB_KEY_0,          togglegaps,     {0} },
227	{ MODKEY|WLR_MODIFIER_LOGO|WLR_MODIFIER_SHIFT,   XKB_KEY_parenright,defaultgaps,    {0} },
228	{ MODKEY,                    XKB_KEY_y,          incihgaps,     {.i = +1 } },
229	{ MODKEY,                    XKB_KEY_o,          incihgaps,     {.i = -1 } },
230	{ MODKEY|WLR_MODIFIER_CTRL,  XKB_KEY_y,          incivgaps,     {.i = +1 } },
231	{ MODKEY|WLR_MODIFIER_CTRL,  XKB_KEY_o,          incivgaps,     {.i = -1 } },
232	{ MODKEY|WLR_MODIFIER_LOGO,  XKB_KEY_y,          incohgaps,     {.i = +1 } },
233	{ MODKEY|WLR_MODIFIER_LOGO,  XKB_KEY_o,          incohgaps,     {.i = -1 } },
234	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Y,          incovgaps,     {.i = +1 } },
235	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_O,          incovgaps,     {.i = -1 } },
236  { WLR_MODIFIER_ALT,          XKB_KEY_R,          zoomreset,     {0} },
237  { MODKEY, XKB_KEY_equal, zoom,      {.f =  +0.1f} },
238  { MODKEY, XKB_KEY_minus, zoom,      {.f = -0.1f} },
239	/* Ctrl-Alt-Backspace and Ctrl-Alt-Fx used to be handled by X server */
240	{ WLR_MODIFIER_CTRL|WLR_MODIFIER_ALT,XKB_KEY_Terminate_Server, quit, {0} },
241	/* Ctrl-Alt-Fx is used to switch to another VT, if you don't know what a VT is
242	 * do not remove them.
243	 */
244#define CHVT(n) { WLR_MODIFIER_CTRL|WLR_MODIFIER_ALT,XKB_KEY_XF86Switch_VT_##n, chvt, {.ui = (n)} }
245	CHVT(1), CHVT(2), CHVT(3), CHVT(4), CHVT(5), CHVT(6),
246	CHVT(7), CHVT(8), CHVT(9), CHVT(10), CHVT(11), CHVT(12),
247};
248
249static const Button buttons[] = {
250	{ ClkClient, MODKEY, BTN_LEFT,   moveresize,     {.ui = CurMove} },
251  { ClkRoot, 0,BTN_MIDDLE,   spawn,     {.v = menucmd} },
252	{ ClkClient, MODKEY, BTN_MIDDLE, togglefloating, {0} },
253	{ ClkClient, MODKEY, BTN_RIGHT,  moveresize,     {.ui = CurResize} },
254	/* infinite_canvas */
255	{ ClkClient, MODKEY|WLR_MODIFIER_SHIFT, BTN_LEFT, movecanvasmouse, {.f = 2} },
256  { ClkRoot, MODKEY|WLR_MODIFIER_SHIFT, BTN_LEFT, movecanvasmouse, {.f = 2} },
257  { ClkRoot, 0, BTN_LEFT, movecanvasmouse, {.f = 2} },
258	/* infinite_canvas_end */
259  { ClkRoot, 0, BTN_RIGHT, spawn, {.v = termcmd} },
260  { ClkClient, MODKEY, SCROLL_UP, zoom,      {.f =  +0.25} },
261  { ClkClient, MODKEY, SCROLL_DOWN, zoom,      {.f = -0.25f} },
262
263  { ClkRoot, MODKEY, SCROLL_UP, zoom,      {.f =  +0.25f} },
264  { ClkRoot, MODKEY, SCROLL_DOWN, zoom,      {.f = -0.25f} },
265
266  { ClkRoot, 0, SCROLL_UP, zoom,      {.f =  +0.25f} },
267  { ClkRoot, 0, SCROLL_DOWN, zoom,      {.f = -0.25f} },
268};
269
270static const TabletButton tabletbuttons[] = {
271    /* button       state                  function    argument */
272/*  { BTN_STYLUS,   WLR_BUTTON_PRESSED,    spawn,      {.v = termcmd} }, */
273/*  { BTN_STYLUS2,  WLR_BUTTON_PRESSED,    killclient, {0} }, */
274	{ 0,            0,                     NULL,       {0} }
275};
276
277static const TabletPadButton tabletpadbuttons[] = {
278	/* button  state                  function          argument */
279/*  { 0,       WLR_BUTTON_PRESSED,    spawn,            {.v = termcmd} }, */
280/*  { 1,       WLR_BUTTON_PRESSED,    killclient,       {0} },*/
281/*  { 2,       WLR_BUTTON_PRESSED,    togglefloating,   {0} },*/
282/*  { 3,       WLR_BUTTON_PRESSED,    zoom,             {0} },*/
283	{ 0,            0,                     NULL,       {0} }
284};