diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2025-06-09 05:38:26 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2025-06-10 05:11:45 +0000 |
| commit | d9675a714016553264ae3b77fee785c6c49d2b6d (patch) | |
| tree | 0df8ca954c70053d0c66a27ceb895cea730e665a | |
| parent | term+input: refactor: move theme switching into term_theme_* functions (diff) | |
main: do a theme toggle upon receiving SIGUSR1
Caveat: in server mode, *all* instances toggle their themes.
| -rw-r--r-- | CHANGELOG.md | 2 | ||||
| -rw-r--r-- | main.c | 17 |
2 files changed, 19 insertions, 0 deletions
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]) @@ -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); |
