theme reload with SIGUSR1
This commit is contained in:
parent
02628f3de3
commit
5c5d33736d
1 changed files with 22 additions and 6 deletions
28
init.lua
28
init.lua
|
|
@ -55,12 +55,28 @@ require("lazy").setup(plugins)
|
|||
|
||||
vim.cmd.colorscheme "catppuccin"
|
||||
|
||||
-- if $XDG_STATE_HOME/darkmode exists, set dark background, light other wise
|
||||
local path = (vim.fn.getenv("XDG_STATE_HOME") or "~/.local/state") .. "/darkmode"
|
||||
if vim.fn.filereadable(path) == 1 then
|
||||
opt.background = "dark"
|
||||
else
|
||||
opt.background = "light"
|
||||
function set_theme_according_to_darkman()
|
||||
local obj = vim.system({ 'darkman', 'get' }, { text = true }):wait()
|
||||
if obj.code == 0 then
|
||||
local theme = "light"
|
||||
if obj.stdout == "dark\n" then
|
||||
theme = "dark"
|
||||
end
|
||||
if obj.stdout == "light\n" then
|
||||
theme = "light"
|
||||
end
|
||||
|
||||
opt.background = theme
|
||||
vim.api.nvim_exec_autocmds("ColorScheme", {})
|
||||
end
|
||||
end
|
||||
|
||||
set_theme_according_to_darkman()
|
||||
vim.api.nvim_create_autocmd("Signal", {
|
||||
pattern = "SIGUSR1",
|
||||
callback = set_theme_according_to_darkman
|
||||
})
|
||||
|
||||
|
||||
|
||||
require("mappings")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue