~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 v3] Add support for custom modes

Details
Message ID
<20231227002229.3174606-2-dezeroku@gmail.com>
DKIM signature
missing
Download raw message
Patch: +24 -13
Implements: https://todo.sr.ht/~emersion/kanshi/80
---
> The indentation uses spaces in this patch, whereas the rest of the codebase
> uses tabs. 
Oops, I have to tune my config, should be fixed now.

> Apart from this, looks good to me.
Cool!

I've also added the "Implements:" to the commit message to test-drive the
SourceHut linking.

 doc/kanshi.5.scd |  3 ++-
 include/config.h |  1 +
 main.c           | 29 +++++++++++++++++------------
 parser.c         |  4 ++++
 4 files changed, 24 insertions(+), 13 deletions(-)

diff --git a/doc/kanshi.5.scd b/doc/kanshi.5.scd
index e14a77b..b007d07 100644
--- a/doc/kanshi.5.scd
+++ b/doc/kanshi.5.scd
@@ -82,7 +82,7 @@ quoted (with *"*) if they contain spaces.
*enable*|*disable*
	Enables or disables the specified output.

*mode* <width>x<height>[@<rate>[Hz]]
*mode* [--custom] <width>x<height>[@<rate>[Hz]]
	Configures the specified output to use the specified mode. Modes are a
	combination of width and height (in pixels) and a refresh rate (in Hz) that
	your display can be configured to use.
@@ -92,6 +92,7 @@ quoted (with *"*) if they contain spaces.
	```
	output HDMI-A-1 mode 1920x1080
	output HDMI-A-1 mode 1920x1080@60Hz
	output HDMI-A-1 mode --custom 1280x720@60Hz
	```

*position* <x>,<y>
diff --git a/include/config.h b/include/config.h
index be01748..047f05b 100644
--- a/include/config.h
+++ b/include/config.h
@@ -22,6 +22,7 @@ struct kanshi_profile_output {
	struct {
		int width, height;
		int refresh; // mHz
		bool custom;
	} mode;
	struct {
		int x, y;
diff --git a/main.c b/main.c
index f21f46c..c7cdd9d 100644
--- a/main.c
+++ b/main.c
@@ -287,20 +287,25 @@ static bool apply_profile(struct kanshi_state *state,
		struct zwlr_output_configuration_head_v1 *config_head =
			zwlr_output_configuration_v1_enable_head(config, head->wlr_head);
		if (profile_output->fields & KANSHI_OUTPUT_MODE) {
			// TODO: support custom modes
			struct kanshi_mode *mode = match_mode(head,
				profile_output->mode.width, profile_output->mode.height,
				profile_output->mode.refresh);
			if (mode == NULL) {
				fprintf(stderr,
					"output '%s' doesn't support mode '%dx%d@%fHz'\n",
					head->name,
			if (profile_output->mode.custom) {
				fprintf(stderr, "applying the custom mode %s\n", profile_output->name);
				zwlr_output_configuration_head_v1_set_custom_mode(config_head,
					profile_output->mode.width, profile_output->mode.height, profile_output->mode.refresh);
			} else {
				struct kanshi_mode *mode = match_mode(head,
					profile_output->mode.width, profile_output->mode.height,
					(float)profile_output->mode.refresh / 1000);
				goto error;
					profile_output->mode.refresh);
				if (mode == NULL) {
					fprintf(stderr,
						"output '%s' doesn't support mode '%dx%d@%fHz'\n",
						head->name,
						profile_output->mode.width, profile_output->mode.height,
						(float)profile_output->mode.refresh / 1000);
					goto error;
				}
				zwlr_output_configuration_head_v1_set_mode(config_head,
						mode->wlr_mode);
			}
			zwlr_output_configuration_head_v1_set_mode(config_head,
				mode->wlr_mode);
		}
		if (profile_output->fields & KANSHI_OUTPUT_POSITION) {
			zwlr_output_configuration_head_v1_set_position(config_head,
diff --git a/parser.c b/parser.c
index ac22c00..21ae248 100644
--- a/parser.c
+++ b/parser.c
@@ -322,6 +322,10 @@ static struct kanshi_profile_output *parse_profile_output(
				char *value = parser->tok_str;
				switch (key) {
				case KANSHI_OUTPUT_MODE:
					if (strcmp(value, "--custom") == 0) {
						output->mode.custom = true;
						continue;
					}
					if (!parse_mode(output, value)) {
						return NULL;
					}
-- 
2.43.0

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

builds.sr.ht <builds@sr.ht>
Details
Message ID
<CXYOS3YS9TLI.XH1WYE89MCW4@cirno2>
In-Reply-To
<20231227002229.3174606-2-dezeroku@gmail.com> (view parent)
DKIM signature
missing
Download raw message
kanshi/patches/.build.yml: SUCCESS in 27s

[Add support for custom modes][0] v3 from [dezeroku][1]

[0]: https://lists.sr.ht/~emersion/public-inbox/patches/48083
[1]: dezeroku@gmail.com

✓ #1121673 SUCCESS kanshi/patches/.build.yml https://builds.sr.ht/~emersion/job/1121673
Details
Message ID
<So5bWtSa2mggQSn5DZI3WxbXdYb-pdoVO15q9NhXELseZyk1opZMwOQP3HgthjgPdyLk4n5aYsbfVKyhiA1oufF8iB5RPTisI-5JmUhIE2c=@emersion.fr>
In-Reply-To
<20231227002229.3174606-2-dezeroku@gmail.com> (view parent)
DKIM signature
missing
Download raw message
Pushed, thanks!
Reply to thread Export thread (mbox)