Created
June 14, 2025 15:26
-
-
Save rvighne/526f10a4f7432233fcb5a3d919bcdb5e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function s:AppsUseLightTheme() | |
silent let l:output = system('reg query HKCU\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize /v AppsUseLightTheme') | |
silent let l:match = matchlist(l:output, '\s\+AppsUseLightTheme\s\+REG_DWORD\s\+\(\S\+\)') | |
return str2nr(l:match[1], 16) | |
endfunction | |
function s:SyncBackground() | |
if s:AppsUseLightTheme() | |
set background=light | |
else | |
set background=dark | |
endif | |
endfunction | |
" FocusGained would be much nicer UX but it fires constantly for some reason | |
autocmd myvimrc GUIEnter * call s:SyncBackground() | |
autocmd myvimrc FocusLost * call s:SyncBackground() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment