local fwatch = require("fwatch") function Set_theme_at(path) local f = io.open(path, "rb") if not f then return nil end local theme = f:read("*a") theme = theme:gsub("%s+", "") f:close() vim.schedule(function() if (theme == "light") then vim.api.nvim_set_option("background", "light") vim.cmd("colorscheme catppuccin-latte") else vim.api.nvim_set_option("background", "dark") vim.cmd("colorscheme catppuccin-mocha") end end) end fwatch.watch(os.getenv("HOME") .. "/theme", { on_event = Set_theme_at }) Set_theme_at(os.getenv("HOME") .. "/theme")