From 879352f129939961ff1aab289b5eeadeb73c784b Mon Sep 17 00:00:00 2001 From: Mars-Wave <57585293+Mars-Wave@users.noreply.github.com> Date: Tue, 10 Mar 2026 19:41:12 +0100 Subject: [PATCH] Keep comments inside block-form kanshi outputs --- src/store.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/store.c b/src/store.c index 20ed86e..5c57c21 100644 --- a/src/store.c +++ b/src/store.c @@ -415,6 +415,19 @@ static void append_settings(GString *str, struct wd_head_config *output, g_string_append_c(str, '\n'); } +static void append_comments(GString *str, const char *text, + struct kanshi_directive *dir) { + const char *end = text + dir->end; + const char *line = strchr(text + dir->name_start, '\n'); + while (line != NULL && ++line < end) { + const char *next = strchr(line, '\n'); + if (line[strspn(line, " \t")] == '#') { + g_string_append_len(str, line, (next != NULL ? next + 1 : end) - line); + } + line = next; + } +} + static void rewrite_profile(GString *str, const char *text, struct kanshi_directive *profile, struct wd_head_config **heads, int num_heads, struct kanshi_directive **matches) { @@ -429,6 +442,7 @@ static void rewrite_profile(GString *str, const char *text, } for (int j = 0; j < num_heads; j++) { if (matches[j] == child) { + append_comments(str, text, child); g_string_append_len(str, text + child->start, child->name_start - child->start); g_string_append(str, "output ");