diff options
Diffstat (limited to 'sway/config.c')
-rw-r--r-- | sway/config.c | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/sway/config.c b/sway/config.c index 89b7d349..d0e0e432 100644 --- a/sway/config.c +++ b/sway/config.c | |||
@@ -276,12 +276,12 @@ static char *get_config_path(void) { | |||
276 | char *home = getenv("HOME"); | 276 | char *home = getenv("HOME"); |
277 | char *config_home = malloc(strlen(home) + strlen("/.config") + 1); | 277 | char *config_home = malloc(strlen(home) + strlen("/.config") + 1); |
278 | if (!config_home) { | 278 | if (!config_home) { |
279 | wlr_log(L_ERROR, "Unable to allocate $HOME/.config"); | 279 | wlr_log(WLR_ERROR, "Unable to allocate $HOME/.config"); |
280 | } else { | 280 | } else { |
281 | strcpy(config_home, home); | 281 | strcpy(config_home, home); |
282 | strcat(config_home, "/.config"); | 282 | strcat(config_home, "/.config"); |
283 | setenv("XDG_CONFIG_HOME", config_home, 1); | 283 | setenv("XDG_CONFIG_HOME", config_home, 1); |
284 | wlr_log(L_DEBUG, "Set XDG_CONFIG_HOME to %s", config_home); | 284 | wlr_log(WLR_DEBUG, "Set XDG_CONFIG_HOME to %s", config_home); |
285 | free(config_home); | 285 | free(config_home); |
286 | } | 286 | } |
287 | } | 287 | } |
@@ -308,11 +308,11 @@ const char *current_config_path; | |||
308 | 308 | ||
309 | static bool load_config(const char *path, struct sway_config *config) { | 309 | static bool load_config(const char *path, struct sway_config *config) { |
310 | if (path == NULL) { | 310 | if (path == NULL) { |
311 | wlr_log(L_ERROR, "Unable to find a config file!"); | 311 | wlr_log(WLR_ERROR, "Unable to find a config file!"); |
312 | return false; | 312 | return false; |
313 | } | 313 | } |
314 | 314 | ||
315 | wlr_log(L_INFO, "Loading config from %s", path); | 315 | wlr_log(WLR_INFO, "Loading config from %s", path); |
316 | current_config_path = path; | 316 | current_config_path = path; |
317 | 317 | ||
318 | struct stat sb; | 318 | struct stat sb; |
@@ -322,7 +322,7 @@ static bool load_config(const char *path, struct sway_config *config) { | |||
322 | 322 | ||
323 | FILE *f = fopen(path, "r"); | 323 | FILE *f = fopen(path, "r"); |
324 | if (!f) { | 324 | if (!f) { |
325 | wlr_log(L_ERROR, "Unable to open %s for reading", path); | 325 | wlr_log(WLR_ERROR, "Unable to open %s for reading", path); |
326 | return false; | 326 | return false; |
327 | } | 327 | } |
328 | 328 | ||
@@ -330,7 +330,7 @@ static bool load_config(const char *path, struct sway_config *config) { | |||
330 | fclose(f); | 330 | fclose(f); |
331 | 331 | ||
332 | if (!config_load_success) { | 332 | if (!config_load_success) { |
333 | wlr_log(L_ERROR, "Error(s) loading config!"); | 333 | wlr_log(WLR_ERROR, "Error(s) loading config!"); |
334 | } | 334 | } |
335 | 335 | ||
336 | current_config_path = NULL; | 336 | current_config_path = NULL; |
@@ -353,7 +353,7 @@ bool load_main_config(const char *file, bool is_active) { | |||
353 | 353 | ||
354 | config_defaults(config); | 354 | config_defaults(config); |
355 | if (is_active) { | 355 | if (is_active) { |
356 | wlr_log(L_DEBUG, "Performing configuration file reload"); | 356 | wlr_log(WLR_DEBUG, "Performing configuration file reload"); |
357 | config->reloading = true; | 357 | config->reloading = true; |
358 | config->active = true; | 358 | config->active = true; |
359 | } | 359 | } |
@@ -369,7 +369,7 @@ bool load_main_config(const char *file, bool is_active) { | |||
369 | /* | 369 | /* |
370 | DIR *dir = opendir(SYSCONFDIR "/sway/security.d"); | 370 | DIR *dir = opendir(SYSCONFDIR "/sway/security.d"); |
371 | if (!dir) { | 371 | if (!dir) { |
372 | wlr_log(L_ERROR, | 372 | wlr_log(WLR_ERROR, |
373 | "%s does not exist, sway will have no security configuration" | 373 | "%s does not exist, sway will have no security configuration" |
374 | " and will probably be broken", SYSCONFDIR "/sway/security.d"); | 374 | " and will probably be broken", SYSCONFDIR "/sway/security.d"); |
375 | } else { | 375 | } else { |
@@ -398,7 +398,7 @@ bool load_main_config(const char *file, bool is_active) { | |||
398 | if (stat(_path, &s) || s.st_uid != 0 || s.st_gid != 0 || | 398 | if (stat(_path, &s) || s.st_uid != 0 || s.st_gid != 0 || |
399 | (((s.st_mode & 0777) != 0644) && | 399 | (((s.st_mode & 0777) != 0644) && |
400 | (s.st_mode & 0777) != 0444)) { | 400 | (s.st_mode & 0777) != 0444)) { |
401 | wlr_log(L_ERROR, | 401 | wlr_log(WLR_ERROR, |
402 | "Refusing to load %s - it must be owned by root " | 402 | "Refusing to load %s - it must be owned by root " |
403 | "and mode 644 or 444", _path); | 403 | "and mode 644 or 444", _path); |
404 | success = false; | 404 | success = false; |
@@ -436,7 +436,7 @@ static bool load_include_config(const char *path, const char *parent_dir, | |||
436 | len = len + strlen(parent_dir) + 2; | 436 | len = len + strlen(parent_dir) + 2; |
437 | full_path = malloc(len * sizeof(char)); | 437 | full_path = malloc(len * sizeof(char)); |
438 | if (!full_path) { | 438 | if (!full_path) { |
439 | wlr_log(L_ERROR, | 439 | wlr_log(WLR_ERROR, |
440 | "Unable to allocate full path to included config"); | 440 | "Unable to allocate full path to included config"); |
441 | return false; | 441 | return false; |
442 | } | 442 | } |
@@ -449,7 +449,7 @@ static bool load_include_config(const char *path, const char *parent_dir, | |||
449 | free(full_path); | 449 | free(full_path); |
450 | 450 | ||
451 | if (real_path == NULL) { | 451 | if (real_path == NULL) { |
452 | wlr_log(L_DEBUG, "%s not found.", path); | 452 | wlr_log(WLR_DEBUG, "%s not found.", path); |
453 | return false; | 453 | return false; |
454 | } | 454 | } |
455 | 455 | ||
@@ -458,7 +458,7 @@ static bool load_include_config(const char *path, const char *parent_dir, | |||
458 | for (j = 0; j < config->config_chain->length; ++j) { | 458 | for (j = 0; j < config->config_chain->length; ++j) { |
459 | char *old_path = config->config_chain->items[j]; | 459 | char *old_path = config->config_chain->items[j]; |
460 | if (strcmp(real_path, old_path) == 0) { | 460 | if (strcmp(real_path, old_path) == 0) { |
461 | wlr_log(L_DEBUG, | 461 | wlr_log(WLR_DEBUG, |
462 | "%s already included once, won't be included again.", | 462 | "%s already included once, won't be included again.", |
463 | real_path); | 463 | real_path); |
464 | free(real_path); | 464 | free(real_path); |
@@ -512,7 +512,7 @@ bool load_include_configs(const char *path, struct sway_config *config) { | |||
512 | // restore wd | 512 | // restore wd |
513 | if (chdir(wd) < 0) { | 513 | if (chdir(wd) < 0) { |
514 | free(wd); | 514 | free(wd); |
515 | wlr_log(L_ERROR, "failed to restore working directory"); | 515 | wlr_log(WLR_ERROR, "failed to restore working directory"); |
516 | return false; | 516 | return false; |
517 | } | 517 | } |
518 | 518 | ||
@@ -527,13 +527,13 @@ static int detect_brace_on_following_line(FILE *file, char *line, | |||
527 | char *peeked = NULL; | 527 | char *peeked = NULL; |
528 | long position = 0; | 528 | long position = 0; |
529 | do { | 529 | do { |
530 | wlr_log(L_DEBUG, "Peeking line %d", line_number + lines + 1); | 530 | wlr_log(WLR_DEBUG, "Peeking line %d", line_number + lines + 1); |
531 | free(peeked); | 531 | free(peeked); |
532 | peeked = peek_line(file, lines, &position); | 532 | peeked = peek_line(file, lines, &position); |
533 | if (peeked) { | 533 | if (peeked) { |
534 | peeked = strip_whitespace(peeked); | 534 | peeked = strip_whitespace(peeked); |
535 | } | 535 | } |
536 | wlr_log(L_DEBUG, "Peeked line: `%s`", peeked); | 536 | wlr_log(WLR_DEBUG, "Peeked line: `%s`", peeked); |
537 | lines++; | 537 | lines++; |
538 | } while (peeked && strlen(peeked) == 0); | 538 | } while (peeked && strlen(peeked) == 0); |
539 | 539 | ||
@@ -552,7 +552,7 @@ static char *expand_line(const char *block, const char *line, bool add_brace) { | |||
552 | + (add_brace ? 2 : 0) + 1; | 552 | + (add_brace ? 2 : 0) + 1; |
553 | char *expanded = calloc(1, size); | 553 | char *expanded = calloc(1, size); |
554 | if (!expanded) { | 554 | if (!expanded) { |
555 | wlr_log(L_ERROR, "Cannot allocate expanded line buffer"); | 555 | wlr_log(WLR_ERROR, "Cannot allocate expanded line buffer"); |
556 | return NULL; | 556 | return NULL; |
557 | } | 557 | } |
558 | snprintf(expanded, size, "%s%s%s%s", block ? block : "", | 558 | snprintf(expanded, size, "%s%s%s%s", block ? block : "", |
@@ -572,7 +572,7 @@ bool read_config(FILE *file, struct sway_config *config) { | |||
572 | continue; | 572 | continue; |
573 | } | 573 | } |
574 | line_number++; | 574 | line_number++; |
575 | wlr_log(L_DEBUG, "Read line %d: %s", line_number, line); | 575 | wlr_log(WLR_DEBUG, "Read line %d: %s", line_number, line); |
576 | line = strip_whitespace(line); | 576 | line = strip_whitespace(line); |
577 | if (line[0] == '#') { | 577 | if (line[0] == '#') { |
578 | free(line); | 578 | free(line); |
@@ -586,7 +586,7 @@ bool read_config(FILE *file, struct sway_config *config) { | |||
586 | line_number); | 586 | line_number); |
587 | if (brace_detected > 0) { | 587 | if (brace_detected > 0) { |
588 | line_number += brace_detected; | 588 | line_number += brace_detected; |
589 | wlr_log(L_DEBUG, "Detected open brace on line %d", line_number); | 589 | wlr_log(WLR_DEBUG, "Detected open brace on line %d", line_number); |
590 | } | 590 | } |
591 | char *expanded = expand_line(block, line, brace_detected > 0); | 591 | char *expanded = expand_line(block, line, brace_detected > 0); |
592 | if (!expanded) { | 592 | if (!expanded) { |
@@ -594,7 +594,7 @@ bool read_config(FILE *file, struct sway_config *config) { | |||
594 | list_free(stack); | 594 | list_free(stack); |
595 | return false; | 595 | return false; |
596 | } | 596 | } |
597 | wlr_log(L_DEBUG, "Expanded line: %s", expanded); | 597 | wlr_log(WLR_DEBUG, "Expanded line: %s", expanded); |
598 | struct cmd_results *res; | 598 | struct cmd_results *res; |
599 | if (block && strcmp(block, "<commands>") == 0) { | 599 | if (block && strcmp(block, "<commands>") == 0) { |
600 | // Special case | 600 | // Special case |
@@ -606,23 +606,23 @@ bool read_config(FILE *file, struct sway_config *config) { | |||
606 | switch(res->status) { | 606 | switch(res->status) { |
607 | case CMD_FAILURE: | 607 | case CMD_FAILURE: |
608 | case CMD_INVALID: | 608 | case CMD_INVALID: |
609 | wlr_log(L_ERROR, "Error on line %i '%s': %s (%s)", line_number, | 609 | wlr_log(WLR_ERROR, "Error on line %i '%s': %s (%s)", line_number, |
610 | line, res->error, config->current_config); | 610 | line, res->error, config->current_config); |
611 | success = false; | 611 | success = false; |
612 | break; | 612 | break; |
613 | 613 | ||
614 | case CMD_DEFER: | 614 | case CMD_DEFER: |
615 | wlr_log(L_DEBUG, "Deferring command `%s'", line); | 615 | wlr_log(WLR_DEBUG, "Deferring command `%s'", line); |
616 | list_add(config->cmd_queue, strdup(line)); | 616 | list_add(config->cmd_queue, strdup(line)); |
617 | break; | 617 | break; |
618 | 618 | ||
619 | case CMD_BLOCK_COMMANDS: | 619 | case CMD_BLOCK_COMMANDS: |
620 | wlr_log(L_DEBUG, "Entering commands block"); | 620 | wlr_log(WLR_DEBUG, "Entering commands block"); |
621 | list_insert(stack, 0, "<commands>"); | 621 | list_insert(stack, 0, "<commands>"); |
622 | break; | 622 | break; |
623 | 623 | ||
624 | case CMD_BLOCK: | 624 | case CMD_BLOCK: |
625 | wlr_log(L_DEBUG, "Entering block '%s'", res->input); | 625 | wlr_log(WLR_DEBUG, "Entering block '%s'", res->input); |
626 | list_insert(stack, 0, strdup(res->input)); | 626 | list_insert(stack, 0, strdup(res->input)); |
627 | if (strcmp(res->input, "bar") == 0) { | 627 | if (strcmp(res->input, "bar") == 0) { |
628 | config->current_bar = NULL; | 628 | config->current_bar = NULL; |
@@ -631,7 +631,7 @@ bool read_config(FILE *file, struct sway_config *config) { | |||
631 | 631 | ||
632 | case CMD_BLOCK_END: | 632 | case CMD_BLOCK_END: |
633 | if (!block) { | 633 | if (!block) { |
634 | wlr_log(L_DEBUG, "Unmatched '}' on line %i", line_number); | 634 | wlr_log(WLR_DEBUG, "Unmatched '}' on line %i", line_number); |
635 | success = false; | 635 | success = false; |
636 | break; | 636 | break; |
637 | } | 637 | } |
@@ -639,7 +639,7 @@ bool read_config(FILE *file, struct sway_config *config) { | |||
639 | config->current_bar = NULL; | 639 | config->current_bar = NULL; |
640 | } | 640 | } |
641 | 641 | ||
642 | wlr_log(L_DEBUG, "Exiting block '%s'", block); | 642 | wlr_log(WLR_DEBUG, "Exiting block '%s'", block); |
643 | list_del(stack, 0); | 643 | list_del(stack, 0); |
644 | free(block); | 644 | free(block); |
645 | memset(&config->handler_context, 0, | 645 | memset(&config->handler_context, 0, |
@@ -682,7 +682,7 @@ char *do_var_replacement(char *str) { | |||
682 | int vvlen = strlen(var->value); | 682 | int vvlen = strlen(var->value); |
683 | char *newstr = malloc(strlen(str) - vnlen + vvlen + 1); | 683 | char *newstr = malloc(strlen(str) - vnlen + vvlen + 1); |
684 | if (!newstr) { | 684 | if (!newstr) { |
685 | wlr_log(L_ERROR, | 685 | wlr_log(WLR_ERROR, |
686 | "Unable to allocate replacement " | 686 | "Unable to allocate replacement " |
687 | "during variable expansion"); | 687 | "during variable expansion"); |
688 | break; | 688 | break; |