Allow automatic light/dark mode detection from applications running within the terminal (CSI 2031)
Through Lua scripting, Wezterm already allows for automatic switching between light and dark themes. However, applications running within the terminal are unaware of this and don't receive any kind of notification when the switching takes place. A consequence of this is that in some cases, the readability is far from optimal due to insufficient contrast between the background color and the colors from the chosen theme of the app itself.
Recently, a few other terminal emulators and applications have implemented a simple protocol for dark/light mode detection and update notifications. For documentation, see: https://github.com/contour-terminal/contour/blob/f3c3334aa5c861348c5bbe8ffe572c872eef2e08/docs/vt-extensions/color-palette-update-notifications.md
Terminal emulators that are implementing CSI 2031 are:
- Ghostty
- Contour
- Kitty
- Tmux
Applications that take advantage of CSI 2031 are:
- Neovim: https://github.com/neovim/neovim/pull/31350
- Tmux
- (probably others.)
The request here is to make sure that applications running in Wezterm can query the current theme (light/dark), but can also use CSI 2031 to subscribe to theme updates.
FYI there are a couple of follow-up proposals to the specification. If Wezterm implements this then I suggest also following these threads:
- https://github.com/contour-terminal/contour/discussions/1657
- https://github.com/contour-terminal/contour/issues/1659