-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Add mode 2031 support (automatic dark/light mode) #4353
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
Conversation
Co-Author: Nicholas Marriott <nicholas.marriott@gmail.com>
|
Good stuff, thanks - let me know when you have the last bits finished. |
|
@nicm : The last bit is finished now. That's the second commit in this PR. Hope this is good to be merged. ;) edit: for clarity, moving the final piece that is now addressed below in this comment, out of the PR description:
|
|
I am not familiar with C lang so please disregard this if it's something obvious. When I compiled from this branch I had to update diff --git a/tmux.h b/tmux.h
index 3d1ee2dc..30001fbd 100644
--- a/tmux.h
+++ b/tmux.h
@@ -2944,6 +2944,7 @@ void input_reply_clipboard(struct bufferevent *, const char *, size_t,
void input_set_buffer_size(size_t);
int input_get_bg_client(struct window_pane *);
int input_get_bg_control_client(struct window_pane *);
+int window_get_bg_client(struct window_pane *);
/* input-key.c */
void input_key_build(void);
@@ -3260,7 +3261,10 @@ void window_set_fill_character(struct window *);
void window_pane_default_cursor(struct window_pane *);
int window_pane_mode(struct window_pane *);
int window_pane_show_scrollbar(struct window_pane *, int);
+int window_pane_get_fg(struct window_pane *);
int window_pane_get_bg(struct window_pane *);
+int window_pane_get_fg_control_client(struct window_pane *);
+int window_pane_get_bg_control_client(struct window_pane *);
enum client_theme window_pane_get_theme(struct window_pane *);
void window_pane_send_theme_update(struct window_pane *);afterwards it compiled successfully. (macOS 15.3.1) ./autogen.sh
./configure --enable-utf8proc && make |
|
@disrupted : I pushed a commit that includes these missing headers. Looks like in my case, on Linux, these were only warnings. Can you try again? |
2a7758e to
b448f4b
Compare
|
thanks! It does work now |
|
I've been using this branch for a while already together with Neovim nightly. What I noticed is that when I toggle the system appearance (light/dark) all nvim instances of the current tmux session toggle the background/colorscheme correctly. But when I switch to another tmux session, those nvim instances keep their previous appearance. |
…ession adapt to the client's theme.
|
@disrupted : Thanks for testing! Now, with the latest commit, all terminal apps should immediately receive a theme update when toggling sessions (if they are subscribed for theme updates). Can you try again? |
|
can confirm, it works great now! Thanks a lot for working on this |
… to the terminal application.
|
This looks good and works for me, at least when I run tmux inside another tmux. I've applied it to OpenBSD now with a minor change to Thanks! |
|
Thanks for merging! |
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
Adds a new alias 'b' for the 'bun' command. Removes the '--listen' flag from the 'e' ($EDITOR) alias. Old behaviour was wrong <neovim/neovim#33150 (comment)>
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. |
See: #4269
This PR implements:
client_themevariable for usage in the formatting.client-dark-themeandclient-light-themethat allows a tmux config to respond to theme changes and update colors.Usage instructions
For anyone coming across this PR:
~/.config/ghostty/config, do:client-{dark,light}-themeevents. In these shell scripts, you can then perform tmux commands that toggle the style of the status bar and tmux panes.For debugging, you can display the theme in the status bar:
bgsetting between light and dark following tmux and ghostty. Then use a color scheme like rose-pine that follows the bg setting.Testing the protocol
Query whether mode 2031 is supported (should return
<csi>?2031;2$y):Within a tmux pane, the following should report the current theme (
<CSI>?997;1nfor light a<CSI>?997;2nfor dark):To subscribe for theme updates:
To unsubscribe:
When tmux is styled with a background color of its own, this should automatically be taken into account and reported whenever this changes. Do
echo -e "\e[?2031h"and then type the following in the tmux prompt: