~emersion/public-inbox

kanshi: Attempt switching all profiles with the same name v1 APPLIED

Tom Lebreux: 1
 Attempt switching all profiles with the same name

 1 files changed, 10 insertions(+), 5 deletions(-)
#1210152 .build.yml success
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~emersion/public-inbox/patches/51512/mbox | git am -3
Learn more about email & git

[PATCH kanshi] Attempt switching all profiles with the same name Export this patch

---
For example, if I have the following profiles:

profile "lid-opened" {
	output eDP-1 enable mode 1920x1080 position 0,0 scale 1
	output "screen2" enable
}

profile "lid-opened" {
	output eDP-1 enable mode 1920x1080 position 0,0 scale 1.6
	output "screen3" enable
}

with a sway bindswitch on lid-opened whenever the lid open, we should try all
profiles until one matches. Otherwise, it will fail to switch to
lid-opened if I'm connected to screen3.

 ipc.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/ipc.c b/ipc.c
index f8242215ff1d..fe61f63d929b 100644
--- a/ipc.c
+++ b/ipc.c
@@ -48,18 +48,23 @@ static long handle_switch(VarlinkService *service, VarlinkCall *call,

	struct kanshi_profile *profile;
	bool found = false;
	bool matched = false;
	wl_list_for_each(profile, &state->config->profiles, link) {
		if (strcmp(profile->name, profile_name) == 0) {
			found = true;
		if (strcmp(profile->name, profile_name) != 0) {
			continue;
		}

		found = true;
		if (kanshi_switch(state, profile, apply_profile_done, call)) {
			matched = true;
			break;
		}
	}
	if (!found) {
		return reply_error(call, "fr.emersion.kanshi.ProfileNotFound");
	}

	if (!kanshi_switch(state, profile, apply_profile_done, call)) {
		return reply_error(call, "fr.emersion.kanshi.ProfileNotMatched");
	if (!matched) {
			return reply_error(call, "fr.emersion.kanshi.ProfileNotMatched");
	}

	return 0;
-- 
2.44.0
kanshi/patches/.build.yml: SUCCESS in 36s

[Attempt switching all profiles with the same name][0] from [Tom Lebreux][1]

[0]: https://lists.sr.ht/~emersion/public-inbox/patches/51512
[1]: mailto:me@tomlebreux.com

✓ #1210152 SUCCESS kanshi/patches/.build.yml https://builds.sr.ht/~emersion/job/1210152
Pushed, thanks!