---
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