Debian Codegraph @

src/config.c

raw symbols SCIP
1 // SPDX-License-Identifier: MIT
2 // Copyright (c) 2011-2013, Christopher Jeffrey
3 // Copyright (c) 2013 Richard Grenville <[email protected]>
4 // Copyright (c) 2018 Yuxuan Shui <[email protected]>
5
6 #include <ctype.h>
7 #include <dlfcn.h>
8 #include <fcntl.h>
9 #include <limits.h>
10 #include <stdbool.h>
11 #include <stddef.h>
12 #include <stdio.h>
13 #include <stdlib.h>
14 #include <string.h>
15 #include <sys/stat.h>
16 #include <sys/types.h>
17 #include <unistd.h>
18 #include <xcb/render.h> // for xcb_render_fixed_t, XXX
19
20 #include <picom/types.h>
21 #include <test.h>
22
23 #include "common.h"
24 #include "log.h"
25 #include "utils/dynarr.h"
26 #include "utils/kernel.h"
27 #include "utils/str.h"
28
29 #include "config.h"
30
31 struct debug_options global_debug_options;
32
33 const char *xdg_config_home(void) {
34 char *xdgh = getenv("XDG_CONFIG_HOME");
35 char *home = getenv("HOME");
36 const char *default_dir = "/.config";
37
38 if (!xdgh) {
39 if (!home) {
40 return NULL;
41 }
42
43 xdgh = mstrjoin(home, default_dir);
44 } else {
45 xdgh = strdup(xdgh);
46 }
47
48 return xdgh;
49 }
50
51 char **xdg_config_dirs(void) {
52 char *xdgd = getenv("XDG_CONFIG_DIRS");
53 size_t count = 0;
54
55 if (!xdgd) {
56 xdgd = "/etc/xdg";
57 }
58
59 for (int i = 0; xdgd[i]; i++) {
60 if (xdgd[i] == ':') {
61 count++;
62 }
63 }
64
65 // Store the string and the result pointers together so they can be
66 // freed together
67 char **dir_list = cvalloc(sizeof(char *) * (count + 2) + strlen(xdgd) + 1);
68 auto dirs = strcpy((char *)dir_list + sizeof(char *) * (count + 2), xdgd);
69 auto path = dirs;
70
71 for (size_t i = 0; i < count; i++) {
72 dir_list[i] = path;
73 path = strchr(path, ':');
74 *path = '\0';
75 path++;
76 }
77 dir_list[count] = path;
78
79 size_t fill = 0;
80 for (size_t i = 0; i <= count; i++) {
81 if (dir_list[i][0] == '/') {
82 dir_list[fill] = dir_list[i];
83 fill++;
84 }
85 }
86
87 dir_list[fill] = NULL;
88
89 return dir_list;
90 }
91
92 TEST_CASE(xdg_config_dirs) {
93 auto old_var = getenv("XDG_CONFIG_DIRS");
94 if (old_var) {
95 old_var = strdup(old_var);
96 }
97 unsetenv("XDG_CONFIG_DIRS");
98
99 auto result = xdg_config_dirs();
100 TEST_STREQUAL(result[0], "/etc/xdg");
101 TEST_EQUAL(result[1], NULL);
102 free(result);
103
104 setenv("XDG_CONFIG_DIRS", ".:.:/etc/xdg:.:/:", 1);
105 result = xdg_config_dirs();
106 TEST_STREQUAL(result[0], "/etc/xdg");
107 TEST_STREQUAL(result[1], "/");
108 TEST_EQUAL(result[2], NULL);
109 free(result);
110
111 setenv("XDG_CONFIG_DIRS", ":", 1);
112 result = xdg_config_dirs();
113 TEST_EQUAL(result[0], NULL);
114 free(result);
115
116 if (old_var) {
117 setenv("XDG_CONFIG_DIRS", old_var, 1);
118 free(old_var);
119 }
120 }
121
122 /**
123 * Parse a long number.
124 */
125 bool parse_long(const char *s, long *dest) {
126 const char *endptr = NULL;
127 long val = strtol(s, (char **)&endptr, 0);
128 if (!endptr || endptr == s) {
129 log_error("Invalid number: %s", s);
130 return false;
131 }
132 while (isspace((unsigned char)*endptr)) {
133 ++endptr;
134 }
135 if (*endptr) {
136 log_error("Trailing characters: %s", s);
137 return false;
138 }
139 *dest = val;
140 return true;
141 }
142
143 /**
144 * Parse an int number.
145 */
146 bool parse_int(const char *s, int *dest) {
147 long val;
148 if (!parse_long(s, &val)) {
149 return false;
150 }
151 if (val > INT_MAX || val < INT_MIN) {
152 log_error("Number exceeded int limits: %ld", val);
153 return false;
154 }
155 *dest = (int)val;
156 return true;
157 }
158
159 /**
160 * Parse a floating-point number in from a string,
161 * also strips the trailing space and comma after the number.
162 *
163 * @param[in] src string to parse
164 * @param[out] dest return the number parsed from the string
165 * @return pointer to the last character parsed
166 */
167 const char *parse_readnum(const char *src, double *dest) {
168 const char *pc = NULL;
169 double val = strtod_simple(src, &pc);
170 if (!pc || pc == src) {
171 log_error("No number found: %s", src);
172 return src;
173 }
174 while (*pc && (isspace((unsigned char)*pc) || *pc == ',')) {
175 ++pc;
176 }
177 *dest = val;
178 return pc;
179 }
180
181 int parse_blur_method(const char *src) {
182 if (strcmp(src, "box") == 0) {
183 return BLUR_METHOD_BOX;
184 }
185 if (strcmp(src, "dual_kawase") == 0) {
186 return BLUR_METHOD_DUAL_KAWASE;
187 }
188 if (strcmp(src, "gaussian") == 0) {
189 return BLUR_METHOD_GAUSSIAN;
190 }
191 if (strcmp(src, "kernel") == 0) {
192 return BLUR_METHOD_KERNEL;
193 }
194 if (strcmp(src, "none") == 0) {
195 return BLUR_METHOD_NONE;
196 }
197 return BLUR_METHOD_INVALID;
198 }
199
200 /**
201 * Parse a matrix.
202 *
203 * @param[in] src the blur kernel string
204 * @param[out] endptr return where the end of kernel is in the string
205 * @param[out] hasneg whether the kernel has negative values
206 */
207 static conv *parse_blur_kern(const char *src, const char **endptr) {
208 int width = 0, height = 0;
209
210 const char *pc = NULL;
211
212 // Get matrix width and height
213 double val = 0.0;
214 pc = parse_readnum(src, &val);
215 if (src == pc) {
216 goto err1;
217 }
218 src = pc;
219 width = (int)val;
220 pc = parse_readnum(src, &val);
221 if (src == pc) {
222 goto err1;
223 }
224 src = pc;
225 height = (int)val;
226
227 // Validate matrix width and height
228 if (width <= 0 || height <= 0) {
229 log_error("Blue kernel width/height can't be negative.");
230 goto err1;
231 }
232 if (!(width % 2 && height % 2)) {
233 log_error("Blur kernel width/height must be odd.");
234 goto err1;
235 }
236 if (width > 16 || height > 16) {
237 log_warn("Blur kernel width/height too large, may slow down"
238 "rendering, and/or consume lots of memory");
239 }
240
241 // Allocate memory
242 conv *matrix = cvalloc(sizeof(conv) + (size_t)(width * height) * sizeof(double));
243
244 // Read elements
245 int skip = height / 2 * width + width / 2;
246 for (int i = 0; i < width * height; ++i) {
247 // Ignore the center element
248 if (i == skip) {
249 matrix->data[i] = 1;
250 continue;
251 }
252 pc = parse_readnum(src, &val);
253 if (src == pc) {
254 goto err2;
255 }
256 src = pc;
257 matrix->data[i] = val;
258 }
259
260 // Detect trailing characters
261 for (; *pc && *pc != ';'; pc++) {
262 if (!isspace((unsigned char)*pc) && *pc != ',') {
263 // TODO(yshui) isspace is locale aware, be careful
264 log_error("Trailing characters in blur kernel string.");
265 goto err2;
266 }
267 }
268
269 // Jump over spaces after ';'
270 if (*pc == ';') {
271 pc++;
272 while (*pc && isspace((unsigned char)*pc)) {
273 ++pc;
274 }
275 }
276
277 // Require an end of string if endptr is not provided, otherwise
278 // copy end pointer to endptr
279 if (endptr) {
280 *endptr = pc;
281 } else if (*pc) {
282 log_error("Only one blur kernel expected.");
283 goto err2;
284 }
285
286 // Fill in width and height
287 matrix->w = width;
288 matrix->h = height;
289 return matrix;
290
291 err2:
292 free(matrix);
293 err1:
294 return NULL;
295 }
296
297 /**
298 * Parse a list of convolution kernels.
299 *
300 * @param[in] src string to parse
301 * @param[out] hasneg whether any of the kernels have negative values
302 * @return the kernels
303 */
304 struct conv **parse_blur_kern_lst(const char *src, int *count) {
305 // TODO(yshui) just return a predefined kernels, not parse predefined strings...
306 static const struct {
307 const char *name;
308 const char *kern_str;
309 } CONV_KERN_PREDEF[] = {
310 {"3x3box", "3,3,1,1,1,1,1,1,1,1,"},
311 {"5x5box", "5,5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,"},
312 {"7x7box", "7,7,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,"
313 "1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,"},
314 {"3x3gaussian", "3,3,0.243117,0.493069,0.243117,0.493069,0.493069,0.243117,0."
315 "493069,0.243117,"},
316 {"5x5gaussian", "5,5,0.003493,0.029143,0.059106,0.029143,0.003493,0.029143,0."
317 "243117,0.493069,0.243117,0.029143,0.059106,0.493069,0."
318 "493069,0.059106,0.029143,0.243117,0.493069,0.243117,0."
319 "029143,0.003493,0.029143,0.059106,0.029143,0.003493,"},
320 {"7x7gaussian", "7,7,0.000003,0.000102,0.000849,0.001723,0.000849,0.000102,0."
321 "000003,0.000102,0.003493,0.029143,0.059106,0.029143,0."
322 "003493,0.000102,0.000849,0.029143,0.243117,0.493069,0."
323 "243117,0.029143,0.000849,0.001723,0.059106,0.493069,0."
324 "493069,0.059106,0.001723,0.000849,0.029143,0.243117,0."
325 "493069,0.243117,0.029143,0.000849,0.000102,0.003493,0."
326 "029143,0.059106,0.029143,0.003493,0.000102,0.000003,0."
327 "000102,0.000849,0.001723,0.000849,0.000102,0.000003,"},
328 {"9x9gaussian",
329 "9,9,0.000000,0.000000,0.000001,0.000006,0.000012,0.000006,0.000001,0."
330 "000000,0.000000,0.000000,0.000003,0.000102,0.000849,0.001723,0.000849,0."
331 "000102,0.000003,0.000000,0.000001,0.000102,0.003493,0.029143,0.059106,0."
332 "029143,0.003493,0.000102,0.000001,0.000006,0.000849,0.029143,0.243117,0."
333 "493069,0.243117,0.029143,0.000849,0.000006,0.000012,0.001723,0.059106,0."
334 "493069,0.493069,0.059106,0.001723,0.000012,0.000006,0.000849,0.029143,0."
335 "243117,0.493069,0.243117,0.029143,0.000849,0.000006,0.000001,0.000102,0."
336 "003493,0.029143,0.059106,0.029143,0.003493,0.000102,0.000001,0.000000,0."
337 "000003,0.000102,0.000849,0.001723,0.000849,0.000102,0.000003,0.000000,0."
338 "000000,0.000000,0.000001,0.000006,0.000012,0.000006,0.000001,0.000000,0."
339 "000000,"},
340 {"11x11gaussian",
341 "11,11,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0."
342 "000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000001,0."
343 "000006,0.000012,0.000006,0.000001,0.000000,0.000000,0.000000,0.000000,0."
344 "000000,0.000003,0.000102,0.000849,0.001723,0.000849,0.000102,0.000003,0."
345 "000000,0.000000,0.000000,0.000001,0.000102,0.003493,0.029143,0.059106,0."
346 "029143,0.003493,0.000102,0.000001,0.000000,0.000000,0.000006,0.000849,0."
347 "029143,0.243117,0.493069,0.243117,0.029143,0.000849,0.000006,0.000000,0."
348 "000000,0.000012,0.001723,0.059106,0.493069,0.493069,0.059106,0.001723,0."
349 "000012,0.000000,0.000000,0.000006,0.000849,0.029143,0.243117,0.493069,0."
350 "243117,0.029143,0.000849,0.000006,0.000000,0.000000,0.000001,0.000102,0."
351 "003493,0.029143,0.059106,0.029143,0.003493,0.000102,0.000001,0.000000,0."
352 "000000,0.000000,0.000003,0.000102,0.000849,0.001723,0.000849,0.000102,0."
353 "000003,0.000000,0.000000,0.000000,0.000000,0.000000,0.000001,0.000006,0."
354 "000012,0.000006,0.000001,0.000000,0.000000,0.000000,0.000000,0.000000,0."
355 "000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0."
356 "000000,"},
357 };
358
359 *count = 0;
360 for (unsigned int i = 0;
361 i < sizeof(CONV_KERN_PREDEF) / sizeof(CONV_KERN_PREDEF[0]); ++i) {
362 if (strcmp(CONV_KERN_PREDEF[i].name, src) == 0) {
363 return parse_blur_kern_lst(CONV_KERN_PREDEF[i].kern_str, count);
364 }
365 }
366
367 int nkernels = 1;
368 for (int i = 0; src[i]; i++) {
369 if (src[i] == ';') {
370 nkernels++;
371 }
372 }
373
374 struct conv **ret = ccalloc(nkernels, struct conv *);
375
376 int i = 0;
377 const char *pc = src;
378
379 // Continue parsing until the end of source string
380 i = 0;
381 while (pc && *pc) {
382 assert(i < nkernels);
383 ret[i] = parse_blur_kern(pc, &pc);
384 if (!ret[i]) {
385 for (int j = 0; j < i; j++) {
386 free(ret[j]);
387 }
388 free(ret);
389 return NULL;
390 }
391 i++;
392 }
393
394 if (i > 1) {
395 log_warn("You are seeing this message because you are using "
396 "multipass blur. Please report an issue to us so we know "
397 "multipass blur is actually been used. Otherwise it might be "
398 "removed in future releases");
399 }
400
401 *count = i;
402
403 return ret;
404 }
405
406 void *parse_numeric_prefix(const char *src, const char **end, void *user_data) {
407 int *minmax = user_data;
408 *end = NULL;
409 if (!src) {
410 return NULL;
411 }
412
413 // Find numeric value
414 char *endptr = NULL;
415 long val = strtol(src, &endptr, 0);
416 if (!endptr || endptr == src) {
417 log_error("No number specified: %s", src);
418 return NULL;
419 }
420
421 if (val < minmax[0] || val > minmax[1]) {
422 log_error("Number not in range (%d <= n <= %d): %s", minmax[0], minmax[1], src);
423 return NULL;
424 }
425
426 // Skip over spaces
427 while (*endptr && isspace((unsigned char)*endptr)) {
428 ++endptr;
429 }
430 if (':' != *endptr) {
431 log_error("Number separator (':') not found: %s", src);
432 return NULL;
433 }
434 ++endptr;
435
436 *end = endptr;
437
438 return (void *)val;
439 }
440
441 /// Search for auxiliary file under a base directory
442 static char *locate_auxiliary_file_at(const char *base, const char *scope, const char *file) {
443 scoped_charp path = mstrjoin(base, scope);
444 mstrextend(&path, "/");
445 mstrextend(&path, file);
446 if (access(path, O_RDONLY) == 0) {
447 // Canonicalize path to avoid duplicates
448 char *abspath = realpath(path, NULL);
449 return abspath;
450 }
451 return NULL;
452 }
453
454 /**
455 * Get a path of an auxiliary file to read, could be a shader file, or any supplementary
456 * file.
457 *
458 * Follows the XDG specification to search for the shader file in configuration locations.
459 *
460 * The search order is:
461 * 1) If an absolute path is given, use it directly.
462 * 2) Search for the file directly under `include_dir`.
463 * 3) Search for the file in the XDG configuration directories, under path
464 * /picom/<scope>/
465 */
466 char *locate_auxiliary_file(const char *scope, const char *path, const char *include_dir) {
467 if (!path || strlen(path) == 0) {
468 return NULL;
469 }
470
471 // Filename is absolute path, so try to load from there
472 if (path[0] == '/') {
473 if (access(path, O_RDONLY) == 0) {
474 return realpath(path, NULL);
475 }
476 }
477
478 // First try to load file from the include directory (i.e. relative to the
479 // config file)
480 if (include_dir && strlen(include_dir)) {
481 char *ret = locate_auxiliary_file_at(include_dir, "", path);
482 if (ret) {
483 return ret;
484 }
485 }
486
487 // Fall back to searching in user config directory
488 scoped_charp picom_scope = mstrjoin("/picom/", scope);
489 scoped_charp config_home = (char *)xdg_config_home();
490 if (config_home) {
491 char *ret = locate_auxiliary_file_at(config_home, picom_scope, path);
492 if (ret) {
493 return ret;
494 }
495 }
496
497 // Fall back to searching in system config directory
498 auto config_dirs = xdg_config_dirs();
499 for (int i = 0; config_dirs[i]; i++) {
500 char *ret = locate_auxiliary_file_at(config_dirs[i], picom_scope, path);
501 if (ret) {
502 free(config_dirs);
503 return ret;
504 }
505 }
506 free(config_dirs);
507
508 return NULL;
509 }
510
511 struct debug_options_entry {
512 const char *name;
513 const char **choices;
514 size_t offset;
515 };
516
517 // clang-format off
518 const char *vblank_scheduler_str[] = {
519 [VBLANK_SCHEDULER_PRESENT] = "present",
520 [VBLANK_SCHEDULER_SGI_VIDEO_SYNC] = "sgi_video_sync",
521 [LAST_VBLANK_SCHEDULER] = NULL
522 };
523 static const struct debug_options_entry debug_options_entries[] = {
524 {"always_rebind_pixmap" , NULL , offsetof(struct debug_options, always_rebind_pixmap)},
525 {"smart_frame_pacing" , NULL , offsetof(struct debug_options, smart_frame_pacing)},
526 {"force_vblank_sched" , vblank_scheduler_str, offsetof(struct debug_options, force_vblank_scheduler)},
527 {"consistent_buffer_age", NULL , offsetof(struct debug_options, consistent_buffer_age)},
528 };
529 // clang-format on
530
531 void parse_debug_option_single(char *setting, struct debug_options *debug_options) {
532 char *equal = strchr(setting, '=');
533 size_t name_len = equal ? (size_t)(equal - setting) : strlen(setting);
534 for (size_t i = 0; i < ARR_SIZE(debug_options_entries); i++) {
535 if (strncmp(setting, debug_options_entries[i].name, name_len) != 0) {
536 continue;
537 }
538 if (debug_options_entries[i].name[name_len] != '\0') {
539 continue;
540 }
541 auto value = (int *)((void *)debug_options + debug_options_entries[i].offset);
542 if (equal) {
543 const char *const arg = equal + 1;
544 if (debug_options_entries[i].choices != NULL) {
545 for (size_t j = 0; debug_options_entries[i].choices[j]; j++) {
546 if (strcmp(arg, debug_options_entries[i].choices[j]) ==
547 0) {
548 *value = (int)j;
549 return;
550 }
551 }
552 }
553 if (!parse_int(arg, value)) {
554 log_error("Invalid value for debug option %s: %s, it "
555 "will be ignored.",
556 debug_options_entries[i].name, arg);
557 }
558 } else if (debug_options_entries[i].choices == NULL) {
559 *value = 1;
560 } else {
561 log_error(
562 "Missing value for debug option %s, it will be ignored.", setting);
563 }
564 return;
565 }
566 log_error("Invalid debug option: %s", setting);
567 }
568
569 /// Parse debug options from environment variable `PICOM_DEBUG`.
570 void parse_debug_options(struct debug_options *debug_options) {
571 const char *debug = getenv("PICOM_DEBUG");
572 const struct debug_options default_debug_options = {
573 .force_vblank_scheduler = LAST_VBLANK_SCHEDULER,
574 };
575
576 *debug_options = default_debug_options;
577 if (!debug) {
578 return;
579 }
580
581 scoped_charp debug_copy = strdup(debug);
582 char *tmp, *needle = strtok_r(debug_copy, ";", &tmp);
583 while (needle) {
584 parse_debug_option_single(needle, debug_options);
585 needle = strtok_r(NULL, ";", &tmp);
586 }
587 }
588
589 void *parse_window_shader_prefix(const char *src, const char **end, void *user_data) {
590 const char *include_dir = user_data;
591 *end = NULL;
592 if (!src) {
593 return NULL;
594 }
595
596 // Find custom shader terminator
597 const char *endptr = strchr(src, ':');
598 if (!endptr) {
599 log_error("Custom shader terminator not found: %s", src);
600 return NULL;
601 }
602
603 // Parse and create custom shader
604 scoped_charp untrimed_shader_source = strdup(src);
605 if (!untrimed_shader_source) {
606 return NULL;
607 }
608 auto source_end = strchr(untrimed_shader_source, ':');
609 *source_end = '\0';
610
611 size_t length;
612 char *tmp = (char *)trim_both(untrimed_shader_source, &length);
613 tmp[length] = '\0';
614 struct shader_specification *shader_source = NULL;
615
616 if (strcasecmp(tmp, "default") != 0) {
617 char *full_path = locate_auxiliary_file("shaders", tmp, include_dir);
618 if (!full_path) {
619 log_error("Custom shader file \"%s\" not found for rule: %s", tmp, src);
620 return NULL;
621 }
622 shader_source = shader_spec_from_path(full_path);
623 free(full_path);
624 }
625
626 *end = endptr + 1;
627 return shader_source;
628 }
629 void *parse_window_shader_prefix_with_cwd(const char *src, const char **end, void * /*data*/) {
630 scoped_charp cwd = getcwd(NULL, 0);
631 return parse_window_shader_prefix(src, end, cwd);
632 }
633
634 bool load_plugin(const char *name, const char *include_dir) {
635 scoped_charp path = locate_auxiliary_file("plugins", optarg, include_dir);
636 void *handle = NULL;
637 if (!path) {
638 handle = dlopen(name, RTLD_LAZY);
639 } else {
640 log_debug("Plugin %s resolved to %s", name, path);
641 handle = dlopen(path, RTLD_LAZY);
642 }
643 return handle != NULL;
644 }
645
646 bool parse_config(options_t *opt, const char *config_file) {
647 // clang-format off
648 *opt = (struct options){
649 .glx_no_stencil = false,
650 .mark_wmwin_focused = false,
651 .mark_ovredir_focused = false,
652 .detect_rounded_corners = false,
653 .resize_damage = 0,
654 .unredir_if_possible = false,
655 .unredir_if_possible_blacklist = NULL,
656 .unredir_if_possible_delay = 0,
657 .redirected_force = UNSET,
658 .stoppaint_force = UNSET,
659 .dbus = false,
660 .benchmark = 0,
661 .benchmark_wid = XCB_NONE,
662 .logpath = NULL,
663 .log_level = LOG_LEVEL_WARN,
664
665 .use_damage = true,
666 .frame_pacing = true,
667
668 .shadow_red = 0.0,
669 .shadow_green = 0.0,
670 .shadow_blue = 0.0,
671 .shadow_radius = 18,
672 .shadow_offset_x = -15,
673 .shadow_offset_y = -15,
674 .shadow_opacity = .75,
675 .shadow_blacklist = NULL,
676 .shadow_ignore_shaped = false,
677 .crop_shadow_to_monitor = false,
678 .shadow_clip_list = NULL,
679
680 .corner_radius = 0,
681
682 .fade_in_step = 0.028,
683 .fade_out_step = 0.03,
684 .fade_delta = 10,
685 .no_fading_openclose = false,
686 .no_fading_destroyed_argb = false,
687 .fade_blacklist = NULL,
688
689 .inactive_opacity = 1.0,
690 .inactive_opacity_override = false,
691 .active_opacity = 1.0,
692 .frame_opacity = 1.0,
693 .detect_client_opacity = false,
694
695 .blur_method = BLUR_METHOD_NONE,
696 .blur_radius = 3,
697 .blur_deviation = 0.84089642,
698 .blur_strength = 5,
699 .blur_background_frame = false,
700 .blur_background_fixed = false,
701 .blur_background_blacklist = NULL,
702 .blur_kerns = NULL,
703 .blur_kernel_count = 0,
704 .window_shader_fg = NULL,
705 .window_shader_fg_rules = NULL,
706 .inactive_dim = 0.0,
707 .inactive_dim_fixed = false,
708 .invert_color_list = NULL,
709 .opacity_rules = NULL,
710 .max_brightness = 1.0,
711
712 .use_ewmh_active_win = false,
713 .focus_blacklist = NULL,
714 .detect_transient = false,
715 .detect_client_leader = false,
716 .no_ewmh_fullscreen = false,
717
718 .track_leader = false,
719
720 .rounded_corners_blacklist = NULL,
721
722 .rules = NULL,
723 };
724 // clang-format on
725
726 list_init_head(&opt->included_config_files);
727 list_init_head(&opt->unredir_if_possible_blacklist);
728 list_init_head(&opt->paint_blacklist);
729 list_init_head(&opt->shadow_blacklist);
730 list_init_head(&opt->shadow_clip_list);
731 list_init_head(&opt->fade_blacklist);
732 list_init_head(&opt->blur_background_blacklist);
733 list_init_head(&opt->invert_color_list);
734 list_init_head(&opt->window_shader_fg_rules);
735 list_init_head(&opt->opacity_rules);
736 list_init_head(&opt->rounded_corners_blacklist);
737 list_init_head(&opt->corner_radius_rules);
738 list_init_head(&opt->focus_blacklist);
739 list_init_head(&opt->transparent_clipping_blacklist);
740 list_init_head(&opt->rules);
741
742 opt->all_scripts = dynarr_new(struct script *, 4);
743 return parse_config_libconfig(opt, config_file);
744 }