Skip to content

Automatically select light/dark theme based on color-palette-update-notifications #4366

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
cor opened this issue Mar 6, 2025 · 4 comments
Labels
enhancement New feature or request

Comments

@cor
Copy link

cor commented Mar 6, 2025

Is your feature request related to a problem? Please describe.

Most modern operating systems and desktop environments do support Dark and Light themes, this includes at least MacOS, Windows, KDE Plasma, Gnome, and probably others.

Some even support switching from dark to light and light to dark mode based on sun rise / sun set.

In order to not make the terminal emulator look bad after such switch, we must enable the applications inside the terminal to detect when the terminal has updated the color palette. This may happen either due to the operating system having changed the current theme or simply because the user has explicitly requested to reconfigure the currently used theme (e.g. because the user requested to change the terminal profile, also containing a different color scheme).

Describe the solution you'd like
Adopt the color-palette-update-notifications standard.

Describe alternatives you've considered
All other solutions are kinda bad. It's good that we finally have a standard for this.

Additional context
Already supported by Ghostty, Kitty, Neovim, Tmux.
WezTerm, Zellij, and Helix are adding support at the moment.

@cor cor added the enhancement New feature or request label Mar 6, 2025
@stefanhaller
Copy link
Collaborator

Lazygit doesn't have a concept of light or dark themes; it is your terminal emulator that does. And as you say, many of them have support for this already or are adding support for it, so I'm not sure what you think is left for lazygit to do here.

@cor
Copy link
Author

cor commented Mar 6, 2025

Lazygit doesn't have a concept of light or dark themes; it is your terminal emulator that does. And as you say, many of them have support for this already or are adding support for it, so I'm not sure what you think is left for lazygit to do here.

Currently, lazygit only allows you to have one theme configured:

theme:

You can however override this theme by doing something like this on startup:

lazygit --use-config-file="$HOME/.base_lg_conf,$HOME/.light_theme_lg_conf"

but that is an inferior solution, as it means that if you launch Lazygit with your "light theme configuration", and then switch your OS to dark mode, any instance of lazygit that was spawned before the switch will be stuck in the wrong theme.

The ideal solution would be to have two themes in the config, a dark_theme and a light_theme, and implement the color-palette-update-notifications protocol such that currently running instances automatically change on OS theme switch

@stefanhaller
Copy link
Collaborator

I see. So the main feature request is not so much to support automatic switching of light/dark themes, but to add a distinction between light and dark themes in the first place; that's probably the bigger challenge, because it involves some design work (for example, to make it so that the distinction is only relevant for people who care about it, but keep it convenient for those who don't. Personally I don't, and I would like to keep setting my colors unconditionally without having to care about putting them in the right sub-theme).

Once we have that, adding the automatic switching shouldn't be a big deal.

@Dom324
Copy link

Dom324 commented Mar 11, 2025

Another quirk is that the theme information should be ideally passed down to the diff engine, e.g. pager: delta --dark vs pager: delta --light.
(though ideally the diff engine itself would also have support for CSI 2031, and then this isn't needed)

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

3 participants