From 828086008ad2a29634889c80f28d1060729b3bdd Mon Sep 17 00:00:00 2001 From: Stefan Zipproth Date: Fri, 27 Jun 2025 16:34:55 +0200 Subject: [PATCH 1/2] Fix kanshi compatibility by using output names instead of descriptions Kanshi fails to match profiles when output descriptions contain parentheses like 'Iiyama North America PL2294H2 1207823601758 (DP-3)'. According to kanshi(5) manual, valid output criteria are: - Output names (e.g. 'DP-1') - Manufacturer/Model/Serial without parentheses This changes store.c to use head->name (e.g. 'DP-3') instead of head->description, making kanshi profiles work correctly. Fixes 'no profile matched' error when kanshi tries to apply configurations. --- src/store.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/store.c b/src/store.c index 6dab784..21306a6 100644 --- a/src/store.c +++ b/src/store.c @@ -195,12 +195,12 @@ int store_config(struct wl_list *outputs) { } if (description_index < MAX_MONITORS_NUM) { - descriptions[description_index] = strdup(head->description); + descriptions[description_index] = strdup(head->name); // write output config in given format sprintf( outputConfigs[description_index], - "output \"%s\" position %d,%d mode %dx%d@%.4f scale %.2f transform %s", - head->description, output->x, output->y, output->width, + "output %s position %d,%d mode %dx%d@%.4f scale %.2f transform %s", + head->name, output->x, output->y, output->width, output->height, output->refresh / 1.0e3, output->scale, trans_str); description_index++; } else { From 402b3fc6689de28abed518425a0a41526890c185 Mon Sep 17 00:00:00 2001 From: Stefan Zipproth Date: Fri, 27 Jun 2025 22:41:40 +0200 Subject: [PATCH 2/2] Fix profile matching for unquoted output syntax The match() function was still using the old quoted output syntax ("output \"%99[^\"]\"" pattern) which fails to match profiles written with the new unquoted syntax (output DP-3). This caused duplicate profiles to be created instead of updating existing ones. Now supports both quoted (legacy) and unquoted (current) output formats for backward compatibility. --- src/store.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/store.c b/src/store.c index 21306a6..2425ff6 100644 --- a/src/store.c +++ b/src/store.c @@ -108,7 +108,25 @@ struct profile_line match(char **descriptions, int num, char *filename) { while (isspace(*trimmedBuffer)) { trimmedBuffer++; // skip leading spaces } - sscanf(trimmedBuffer, "output \"%99[^\"]\"", outputName); // extract output name + char tempName[MAX_NAME_LENGTH]; + int matched_scan = 0; + + // Try quoted format first (legacy): output "Long Description (DP-3)" + if (sscanf(trimmedBuffer, "output \"%255[^\"]\"", tempName) == 1) { + // Extract output name from parentheses if present: (DP-3) -> DP-3 + char *paren_start = strrchr(tempName, '('); + char *paren_end = strrchr(tempName, ')'); + if (paren_start && paren_end && paren_end > paren_start) { + size_t len = paren_end - paren_start - 1; + strncpy(outputName, paren_start + 1, len); + outputName[len] = '\0'; + matched_scan = 1; + } + } else if (sscanf(trimmedBuffer, "output %99s", outputName) == 1) { + // Try unquoted format: output DP-3 + matched_scan = 1; + } + if (matched_scan != 1) continue; // Skip unparseable lines // check if the output name is in the descriptions bool matched = false; @@ -276,4 +294,4 @@ int store_config(struct wl_list *outputs) { } return 0; -} \ No newline at end of file +}