Changing theme according to time

how can i change my neovim theme according to time no matter i m using neovim or not? i want gruvbox oto be set on 8am, tokyonight with night style on 7pm. is it possible?

1 Like

Check out the dark-notify project GitHub - cormacrelf/dark-notify: Watcher for macOS 10.14+ light/dark mode changes, although I believe it only works on macOS.

1 Like

I haven’t tried it yet, but I think it should work on other operating systems. Because the trigger comes from outside. And at the end of the tutorial there is a description for other OS’s.

check my theme.lua u can find it there

1 Like

Spawn a timer from vim.loop. I use something like this in my config:

function! misc#time_background() abort
lua << EOF
  local timer = vim.loop.new_timer()
  timer:start(0, 600, vim.schedule_wrap(function()
    local hour = tonumber(os.date('%H'))
    -- You can change color scheme here.
    local bg = (hour > 8 and hour < 19) and 'light' or 'dark'
    if vim.o.bg ~= bg then vim.o.bg = bg end
  end))
EOF
endfunction