Skip to content

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

Closed

Description

@cor

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.

Activity

  1. stefanhaller commented on Mar 6, 2025

    @stefanhaller
    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.

  2. cor commented on Mar 6, 2025

    @cor
    Author

    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

  3. stefanhaller commented on Mar 6, 2025

    @stefanhaller
    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.

  4. Dom324 commented on Mar 11, 2025

    @Dom324

    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)

  5. rbhanot4739 commented on Jun 25, 2025

    @rbhanot4739

    I think delta does support detecting the terminal colors and adjusting its light/dark color presets based on them and it seems to work as expected when used as a native pager for git. However, when used as a pager for lazygit the delta color preset does not seem to be applied correctly which means when system switches from dark to light mode or vice-versa I have to manually update the lazygit config to add --dark or --light to the pager settings.

    Not sure if there is a better way to handle that.

  6. pricci1 commented on Oct 29, 2025

    @pricci1

    Related: #4550

  7. pelletencate commented on Nov 6, 2025

    @pelletencate

    I did this as a workaround on macOS - This may not check my actual terminal setup, but it will automatically explicitly add --dark or --light to the delta pager based on whether my macOS system is currently in dark mode or not.

    #!/bin/bash
    # ~/.config/lazygit/delta.sh - Make sure to chmod +x this file
    
    # Check if dark mode is enabled
    if defaults read -g AppleInterfaceStyle &>/dev/null; then
      exec delta --dark "$@"
    else
      exec delta --light "$@"
    fi

    And then use it:

    # ~/.config/lazygit/config.yml
    git:
      paging:
        colorArg: always
        pager: ~/.config/lazygit/delta.sh --paging=never --line-numbers --hyperlinks --hyperlinks-file-link-format="lazygit-edit://{path}:{line}"
  8. pricci1 commented on Nov 11, 2025

    @pricci1

    Good idea. This works for me in KDE Plasma

    #!/usr/bin/env bash
    
    detect_theme() {
      # KDE Plasma
      if command -v plasma-apply-colorscheme &>/dev/null; then
        local theme_list=$(plasma-apply-colorscheme -l 2>/dev/null)
        local current_theme=$(echo "$theme_list" | grep -E '\*.*current' | sed 's/\*//g' | awk '{print $1}')
    
        if [[ "$current_theme" =~ [Ll]ight ]]; then
          echo "light"
          return
        elif [[ "$current_theme" =~ [Dd]ark ]]; then
          echo "dark"
          return
        fi
      fi
    
      # Default
      echo "light"
    }
    
    theme=$(detect_theme)
    
    if [[ "$theme" == "light" ]]; then
      delta --light "$@"
    else
      delta --dark "$@"
    fi
  9. t40mas commented on Nov 14, 2025

    @t40mas

    Another workaround:
    Since delta respects bat theme, you can set themes via env variables.

    # Bat setting
    export BAT_THEME=""
    export BAT_THEME_LIGHT="Catppuccin Latte"
    export BAT_THEME_DARK="Catppuccin Frappe"
    export BAT_STYLE="full,-grid,-header-filesize,-header-filename"
    
    # BAT_THEME
    x=$(defaults read .GlobalPreferences AppleInterfaceStyle 2>/dev/null) # Macos
    if [[ $x = "Dark" ]]
      then
        BAT_THEME=$BAT_THEME_DARK
        FZF_DEFAULT_OPTS=$FLEXOKI_DARK
      else
        BAT_THEME=$BAT_THEME_LIGHT
        FZF_DEFAULT_OPTS=$FLEXOKI_LIGHT
    fi
  10. dive commented on Jan 18, 2026

    @dive

    If you are on macOS, I use this little workaround with a Zsh alias. Here is what I have in my .zshrc:

    if (( $+commands[lazygit] )); then
      LG_THEME="${XDG_CONFIG_HOME}/lazygit/$([[ $(defaults read -g AppleInterfaceStyle 2>/dev/null) == "Dark" ]] \
        && printf %s dark-mode \
        || printf %s light-mode).yml"
      alias lazygit='lazygit --use-config-file="${XDG_CONFIG_HOME}/lazygit/config.yml,${LG_THEME}"'
    fi

    light-mode.yml

    # Catppuccin Latte
    gui:
      authorColors:
        '*': '#b4befe'
      theme:
        activeBorderColor:
          - '#b4befe'
          - bold
        inactiveBorderColor:
          - '#6c7086'
        optionsTextColor:
          - '#89b4fa'
        selectedLineBgColor:
          - '#e6e9ef'
        cherryPickedCommitBgColor:
          - '#bcc0cc'
        cherryPickedCommitFgColor:
          - '#b4befe'
        unstagedChangesColor:
          - '#f38ba8'
        defaultFgColor:
          - '#4c4f69'
        searchingActiveBorderColor:
          - '#f9e2af'

    dark-mode.yml

    # Catppuccin Mocha
    gui:
      authorColors:
        '*': '#b4befe'
      theme:
        activeBorderColor:
          - '#b4befe'
          - bold
        inactiveBorderColor:
          - '#a6adc8'
        optionsTextColor:
          - '#89b4fa'
        selectedLineBgColor:
          - '#313244'
        cherryPickedCommitBgColor:
          - '#45475a'
        cherryPickedCommitFgColor:
          - '#b4befe'
        unstagedChangesColor:
          - '#f38ba8'
        defaultFgColor:
          - '#cdd6f4'
        searchingActiveBorderColor:
          - '#f9e2af'
  11. alberti42 commented on Feb 8, 2026

    @alberti42

    Maybe you already solved all the problems, but if you are still searching for a solution to synchronize TUI apps and your zsh when the OS system switches, I wrote a zsh plugin for that: https://github.com/alberti42/zsh-appearance-control. I found this thread because I was searching on Google for who else was troubled like me not having the terminal properly synced to the OS look. I tested syncing of tmux, Emacs, and Neovim in macOS and Gnome, and it works well.

    Disclaimer: I did not try with lazygit. However, from what I understand, it would fit your case because you have a callback function that you can personalize, and when the OS theme switches, it automatically resyncs env variables and aliases that are relevant to styling your shell. With apps like Neovim and Emacs, the README in zsh-appearance-repo also shows you how, without installing any extra packages, you get immediate theme-syncing with the OS.

    I think, in the long term, the solution based on CSI and DSR communication is the cleanest, but it will take some time before everybody adopts it (could be years for a widespread adoption). So, meanwhile, the plugin zsh-appearance-repo may be helpful in the transition.

  12. stefanhaller commented on Sep 26, 2026

    @stefanhaller
    Collaborator

    Separate dark/light themes are added in #6065; allowing to pass --dark or --light to delta is done in #6063.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions