diff --git a/README.md b/README.md index 95b037f..52b8e0b 100644 --- a/README.md +++ b/README.md @@ -105,11 +105,15 @@ Most of this is now handled natively and needs no configuration: The tmux status bar needs help, because its colours are set explicitly. They live in `tmux-light.conf` and `tmux-dark.conf` — the same layout, with each colour taken from the matching tangere palette index — and `tmux` sources one of them -from three hooks: +from four hooks: - `client-light-theme` / `client-dark-theme` react to a change, - `client-attached` picks the right one for a client that attaches mid-way, since - the two above only fire on a change. + the two above only fire on a change, +- `client-focus-in` re-asks the terminal for its theme (DSR 996). Ghostty's + push is lost when Auto switches while the lid is closed, so the bar would + otherwise wake up in yesterday's colours. The reply is handled exactly like + a pushed change, so the first two hooks do the rest. Because this keys off the terminal's reported theme rather than a schedule, it behaves identically whether the change came from Auto at sunrise/sunset or from diff --git a/tmux b/tmux index 45329ff..41e433b 100644 --- a/tmux +++ b/tmux @@ -55,6 +55,13 @@ set-hook -g client-dark-theme 'source-file ~/.tmux-dark.conf' # client attaches. Sourcing is idempotent, so the overlap is harmless. set-hook -g client-attached 'if -F "#{==:#{client_theme},light}" "source-file ~/.tmux-light.conf" "source-file ~/.tmux-dark.conf"' +# The push from ghostty is lost when the appearance switches while the lid is +# closed, so the bar wakes up in yesterday's colours. Re-ask the terminal +# (DSR 996) whenever the window regains focus; ghostty answers with the +# current theme and tmux treats the reply exactly like a pushed change, so +# the two hooks above do the rest. +set-hook -g client-focus-in 'run-shell -b "printf \"\\033[?996n\" > #{client_tty}"' + # Default before any client has attached and reported a theme. This also # runs on manual reload (`r` below), so check the invoking client's theme # rather than always falling back to dark and clobbering a light session.