Skip to content

Allow automatic light/dark mode detection from applications running within the terminal (CSI 2031) #6454

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jonathanslenders opened this issue Dec 3, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@jonathanslenders
Copy link

jonathanslenders commented Dec 3, 2024

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

Applications that take advantage of CSI 2031 are:

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.

@gpanders
Copy link
Contributor

gpanders commented Dec 3, 2024

FYI there are a couple of follow-up proposals to the specification. If Wezterm implements this then I suggest also following these threads:

vimpostor added a commit to vimpostor/vim-lumen that referenced this issue Mar 6, 2025
The new DEC mode 2031 [0] is a much better fit and already has native
support in neovim [1] and tmux [2].
Most terminal emulators either already support it or have it on the
roadmap [3] so with this mode suddenly being support across the whole
stack, it is a much better choice than listening for theme changes with
an extra plugin.

[0] https://contour-terminal.org/vt-extensions/color-palette-update-notifications/
[1] neovim/neovim#31350
[2] tmux/tmux#4353
[3] wezterm/wezterm#6454
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants