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"
|
vim.cmd.colorscheme "catppuccin"
|
||||||
|
|
||||||
-- if $XDG_STATE_HOME/darkmode exists, set dark background, light other wise
|
function set_theme_according_to_darkman()
|
||||||
local path = (vim.fn.getenv("XDG_STATE_HOME") or "~/.local/state") .. "/darkmode"
|
local obj = vim.system({ 'darkman', 'get' }, { text = true }):wait()
|
||||||
if vim.fn.filereadable(path) == 1 then
|
if obj.code == 0 then
|
||||||
opt.background = "dark"
|
local theme = "light"
|
||||||
else
|
if obj.stdout == "dark\n" then
|
||||||
opt.background = "light"
|
theme = "dark"
|
||||||
|
end
|
||||||
|
if obj.stdout == "light\n" then
|
||||||
|
theme = "light"
|
||||||
|
end
|
||||||
|
|
||||||
|
opt.background = theme
|
||||||
|
vim.api.nvim_exec_autocmds("ColorScheme", {})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
set_theme_according_to_darkman()
|
||||||
|
vim.api.nvim_create_autocmd("Signal", {
|
||||||
|
pattern = "SIGUSR1",
|
||||||
|
callback = set_theme_according_to_darkman
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
require("mappings")
|
require("mappings")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue