diff --git a/vim/rc/ui.rc.vim b/vim/rc/ui.rc.vim index 44c1fe0..f21212d 100644 --- a/vim/rc/ui.rc.vim +++ b/vim/rc/ui.rc.vim @@ -75,10 +75,6 @@ set notitle " Function and command to update colors based on light and dark mode function! UpdateColors() - "If not a mac, let's get out of here - if !IsMac() - return - endif " Get the light color or default to VIM_COLOR let light_color = $VIM_COLOR if !empty($VIM_COLOR_LIGHT) @@ -89,13 +85,17 @@ function! UpdateColors() if !empty($VIM_COLOR_DARK) let dark_color = $VIM_COLOR_DARK endif - " Find out if macOS is in dark mode - let cmd = "osascript - \ -e 'tell application \"System Events\"' - \ -e 'tell appearance preferences' - \ -e 'return dark mode' - \ -e 'end tell' - \ -e 'end tell'" + " Detect using an env variable + let cmd = "echo $IS_DARKMODE" + " On macOS we can do something a bit more fancy + if IsMac() + let cmd = "osascript + \ -e 'tell application \"System Events\"' + \ -e 'tell appearance preferences' + \ -e 'return dark mode' + \ -e 'end tell' + \ -e 'end tell'" + endif let dark_mode = substitute(system(cmd), '\n', '', 'g') " Set colorscheme and background based on mode if dark_mode == 'true' @@ -107,4 +107,5 @@ function! UpdateColors() endif endfunction command! UpdateColors call UpdateColors() +" au BufEnter *.* call UpdateColors() call UpdateColors()