~emersion/public-inbox

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
2 2

[PATCH kanshi] Add support for wildcard in output identifier

Details
Message ID
<20240628154216.36336-3-tarek.marce@free.fr>
DKIM signature
pass
Download raw message
Patch: +6 -4
This patch adds support for wildcard in output identifier. This is
useful in some case where the serial number or the model is not known or
can change. Since it is not possible anymore to have multiple wildcard
output this commit is useful for openspace where the monitors are all
the same model but not the same serial number.

It uses the fnmatch function of the libc to allow shell wildcard pattern
in output name string.

Here is an example of a working configuration:

    profile atWork {
      output eDP-1 mode 1920x1200 position 960,1080
      output "HP Inc. HP E24m G4 CN*" {
            mode 1920x1080
            position 0,0
      }
      output "HP Inc. HP E24u G4 CN*" {
            mode 1920x1080
            position 1920,0
      }
    }

Tarek "Kerat" Marcé

---
 doc/kanshi.5.scd | 7 ++++---
 main.c           | 3 ++-
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/doc/kanshi.5.scd b/doc/kanshi.5.scd
index 74ada4d..29e8a68 100644
--- a/doc/kanshi.5.scd
+++ b/doc/kanshi.5.scd
@@ -71,9 +71,10 @@ quoted (with *"*) if they contain spaces.
	  may change across reboots (depending on kernel driver probe order) or
	  creation order (typically for USB-C docks).
	- A space-separated string containing the output manufacturer, model and
	  serial number (e.g. "Foocorp ASDF 1234"). If one of these fields is
	  missing, it needs to be populated with the string "Unknown" (e.g.
	  "Foocorp ASDF Unknown").
	  serial number (e.g. "Foocorp ASDF 1234"). It is possible to use a shell
	  wildcard pattern (e.g. "Foocorp ASDF 1*") see *glob*(7).
	  If one of these fields is missing, it needs to be populated with the
	  string "Unknown" (e.g. "Foocorp ASDF Unknown").
	- An output alias (e.g. "$work-desk3") defined by an output alias directive.
	  Output aliases can only be used in profile scope.
	- A wildcard "\*", to match any output.
diff --git a/main.c b/main.c
index f575d83..d91b031 100644
--- a/main.c
+++ b/main.c
@@ -1,6 +1,7 @@
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <fnmatch.h>
#include <getopt.h>
#include <limits.h>
#include <signal.h>
@@ -35,7 +36,7 @@ static bool match_profile_output(struct kanshi_profile_output *output,

	return strcmp(output->name, "*") == 0 ||
		strcmp(output->name, head->name) == 0 ||
		strcmp(output->name, identifier) == 0;
		fnmatch(output->name, identifier, 0) == 0;
}

static bool match_profile(struct kanshi_state *state,
-- 
2.45.2

[kanshi/patches/.build.yml] build failed

builds.sr.ht <builds@sr.ht>
Details
Message ID
<D2BRU84LU3E8.2OQVAWSP2KTOS@fra01>
In-Reply-To
<20240628154216.36336-3-tarek.marce@free.fr> (view parent)
DKIM signature
missing
Download raw message
kanshi/patches/.build.yml: FAILED in 27s

[Add support for wildcard in output identifier][0] from [Tarek Marcé][1]

[0]: https://lists.sr.ht/~emersion/public-inbox/patches/53559
[1]: tarek.marce@free.fr

✗ #1262997 FAILED kanshi/patches/.build.yml https://builds.sr.ht/~emersion/job/1262997

Re: [kanshi/patches/.build.yml] build failed

Details
Message ID
<D3MQ3F57YIXS.2O1FHWVL4G7FO@loganconnolly.com>
In-Reply-To
<D2BRU84LU3E8.2OQVAWSP2KTOS@fra01> (view parent)
DKIM signature
pass
Download raw message
+1 for globbing the output name! My original config looked a lot like
your proposal after I saw "wildcard" in the man docs.

My use case is that I would like to version control my kanshi
config, but I am hesistant to do so because I would need to include the
serial code in the output and the hardware belongs to my company.

Otherwise, really awesome project ~emersion and thank you for writing
this patch, Tarek.
Reply to thread Export thread (mbox)