From 01387f9593294f4eb467a162f245e3c712635f35 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Thu, 17 Jul 2025 10:18:17 +0200 Subject: main: SIGUSR1 selects the first color theme, SIGUSR2 the second Before this patch, SIGUSR1 toggled between [colors] and [colors2]. Now, SIGUSR1 changes to [colors], regardless of what the current color theme is, and SIGUSR2 changes to [colors2]. Closes #2144 --- main.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index 37bbb6a7..517d8460 100644 --- a/main.c +++ b/main.c @@ -46,13 +46,22 @@ fdm_sigint(struct fdm *fdm, int signo, void *data) } static bool -fdm_sigusr1(struct fdm *fdm, int signo, void *data) +fdm_sigusr(struct fdm *fdm, int signo, void *data) { struct wayland *wayl = data; - tll_foreach(wayl->terms, it) { - struct terminal *term = it->item; - term_theme_toggle(term); + xassert(signo == SIGUSR1 || signo == SIGUSR2); + + if (signo == SIGUSR1) { + tll_foreach(wayl->terms, it) { + struct terminal *term = it->item; + term_theme_switch_to_1(term); + } + } else { + tll_foreach(wayl->terms, it) { + struct terminal *term = it->item; + term_theme_switch_to_2(term); + } } return true; @@ -621,8 +630,11 @@ main(int argc, char *const *argv) goto out; } - if (!fdm_signal_add(fdm, SIGUSR1, &fdm_sigusr1, wayl)) + if (!fdm_signal_add(fdm, SIGUSR1, &fdm_sigusr, wayl) || + !fdm_signal_add(fdm, SIGUSR2, &fdm_sigusr, wayl)) + { goto out; + } struct sigaction sig_ign = {.sa_handler = SIG_IGN}; sigemptyset(&sig_ign.sa_mask); -- cgit v1.3 From 57ae3bb89c6bf50e70e831e3658e59a6877e9817 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Fri, 18 Jul 2025 17:24:18 +0200 Subject: main: unregister SIGUSR2 on exit --- main.c | 1 + 1 file changed, 1 insertion(+) (limited to 'main.c') diff --git a/main.c b/main.c index 517d8460..f97f21b5 100644 --- a/main.c +++ b/main.c @@ -672,6 +672,7 @@ out: key_binding_manager_destroy(key_binding_manager); reaper_destroy(reaper); fdm_signal_del(fdm, SIGUSR1); + fdm_signal_del(fdm, SIGUSR2); fdm_signal_del(fdm, SIGTERM); fdm_signal_del(fdm, SIGINT); fdm_destroy(fdm); -- cgit v1.3