From d9675a714016553264ae3b77fee785c6c49d2b6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Mon, 9 Jun 2025 07:38:26 +0200 Subject: [PATCH] main: do a theme toggle upon receiving SIGUSR1 Caveat: in server mode, *all* instances toggle their themes. --- CHANGELOG.md | 2 ++ main.c | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b048bda3..82b4238b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -73,6 +73,8 @@ `key-bindings.color-theme-toggle` key bindings. These can be used to switch between the primary and alternative color themes. They are not bound by default. +* Sending `SIGUSR1` to the foot process now triggers a theme switch + (in server mode, **all** instances toggles their themes). * Support for private mode 2031 - [_Dark and Light Mode Detection_](https://contour-terminal.org/vt-extensions/color-palette-update-notifications/) ([#2025][2025]) diff --git a/main.c b/main.c index b9404503..37bbb6a7 100644 --- a/main.c +++ b/main.c @@ -45,6 +45,19 @@ fdm_sigint(struct fdm *fdm, int signo, void *data) return true; } +static bool +fdm_sigusr1(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); + } + + return true; +} + static void print_usage(const char *prog_name) { @@ -608,6 +621,9 @@ main(int argc, char *const *argv) goto out; } + if (!fdm_signal_add(fdm, SIGUSR1, &fdm_sigusr1, wayl)) + goto out; + struct sigaction sig_ign = {.sa_handler = SIG_IGN}; sigemptyset(&sig_ign.sa_mask); if (sigaction(SIGHUP, &sig_ign, NULL) < 0 || @@ -643,6 +659,7 @@ out: wayl_destroy(wayl); key_binding_manager_destroy(key_binding_manager); reaper_destroy(reaper); + fdm_signal_del(fdm, SIGUSR1); fdm_signal_del(fdm, SIGTERM); fdm_signal_del(fdm, SIGINT); fdm_destroy(fdm);