From faba12b660834f65aa759625b04efd9fb7d7a4eb Mon Sep 17 00:00:00 2001 From: Abhinav Date: Fri, 20 Jun 2025 22:27:47 +0100 Subject: add window swallowing the user can now specify which windows can swallow / can be swallowed. --- src/parser.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) (limited to 'src/parser.c') diff --git a/src/parser.c b/src/parser.c index 3fc2856..315013d 100644 --- a/src/parser.c +++ b/src/parser.c @@ -1,6 +1,6 @@ #define _POSIX_C_SOURCE 200809L #include -#include +#include #include #include #include @@ -404,6 +404,41 @@ found: } torun++; } + else if (!strcmp(key, "can_swallow")) { + char *token = strtok(rest, ","); + int i = 0; + while (token && i < 256) { + char *item = strip_quotes(strip(token)); + if (*item) { + cfg->can_swallow[i] = malloc(2 * sizeof(char *)); + if (!cfg->can_swallow[i]) { + fprintf(stderr, "sxwmrc:%d: malloc failed\n", lineno); + break; + } + cfg->can_swallow[i][0] = strdup(item); + cfg->can_swallow[i][1] = NULL; + i++; + } + token = strtok(NULL, ","); + } + } + else if (!strcmp(key, "can_be_swallowed")) { + char *token = strtok(rest, ","); + int i = 0; + while (token && i < 256) { + char *item = strip_quotes(strip(token)); + if (*item) { + cfg->can_be_swallowed[i] = malloc(2 * sizeof(char *)); + if (!cfg->can_be_swallowed[i]) { + break; + } + cfg->can_be_swallowed[i][0] = strdup(item); + cfg->can_be_swallowed[i][1] = NULL; + i++; + } + token = strtok(NULL, ","); + } + } else { fprintf(stderr, "sxwmrc:%d: unknown option '%s'\n", lineno, key); } -- cgit v1.2.3