Open cmer opened 3 years ago
Totally agreed; this would be wonderful! For anyone stumbling upon this who uses zsh on Mac with Terminal.app, this is what I have in the interim:
mcfly_auto_light_mode() {
if [[ $(defaults read -g AppleInterfaceStyle) != 'Dark' ]]; then
export MCFLY_LIGHT=TRUE
fi
}
zsh-defer mcfly_auto_light_mode
(the zsh-defer
is from this plugin)
I'm game if you want to make this change @cmer. I think the determination should be in the mcfly.bash / mcfly.zsh / mcfly.fish scripts that then set the ENV.
I have submitted a PR.
This would apply only to new terminal/tabs right? ie it would not apply for existing ones. I have hacked my .p10k so this gets set on each prompt iteration:
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS+=(mcfly_theme)
function prompt_mcfly_theme() {
if grep -q 'light' ~/.theme_status; then
export MCFLY_LIGHT=TRUE
else unset MCFLY_LIGHT
fi
}
i update ~/.theme_status
dinamically with dark-notify
would love for mcfly to have a config where i could set this (so it checks for the theme on each run) and i could update that file with https://github.com/cormacrelf/dark-notify
For Gnome 43 it works like this:
colorscheme="$(gsettings get org.gnome.desktop.interface color-scheme)"
if [ ! "$colorscheme" = "'prefer-dark'" ]; then
export MCFLY_LIGHT=TRUE
fi
dconf read /org/gnome/desktop/interface/color-scheme 'default' --> light theme 'prefer-dark' --> dark theme
I'd like to propose the following:
If
MCFLY_LIGHT
is set toTRUE
orFALSE
, force McFly to display in the specified mode.If
MCFLY_LIGHT
is NOT set, make a best effort guess to determine which mode to display in, otherwise fall back to dark mode. I was able to detect light/dark mode in some terminals (but not all) with the following Fish script:It'd be awesome if McFly could perform this check every time it is triggered when
MCFLY_LIGHT
is not set to any particular value.The
COLORFGBG
environment variable is set by many terminals such as iTerm2, Rxvt and Konsole. macOS Terminal does NOT set it, however.