I have written the following code to automatically change my neovim theme when the color-scheme changes in gsettings:
;(function()
local stdout = vim.loop.new_pipe(false)
vim.loop.spawn(
'gsettings',
{
args = {'monitor', 'org.gnome.desktop.interface', 'color-scheme'},
stdio = {nil, stdout, nil},
}
)
vim.loop.read_start(stdout, function (_, s)
vim.schedule(function()
s = string.gsub(s, '^%s+', '')
s = string.gsub(s, '%s+$', '')
s = string.gsub(s, '[\n\r]+', ' ')
s = string.match(s, 'color%-scheme: (.*)')
set_bg(s)
end)
end)
end)()
This works, but I noticed that neovim leaves the gsettings process running after exiting. How can I make neovim properly terminate the subprocess?