On my laptop, I frequently swap between a dark and a bright colorscheme for my terminal. I do this by symlinking its configuration file and asking it (termite) to read it without closing using killall -USR1 termite.

I'd like my running neovims to pick up the change somehow, and set background to either dark or light. I've visited this answer and this issue and other places in an effort to find out how to "refresh" neovim. And I'd like to avoid using packages like neovim-remote if possible.

nvim --version

NVIM v0.3.2-964-g7e97587da
Build type: RelWithDebInfo
LuaJIT 2.0.5
Compilation: /usr/bin/cc -march=x86-64 -mtune=generic -O2 -pipe
  -fstack-protector-strong -fno-plt -Wconversion -O2 -g -DMIN_LOG_LEVEL=3 
  -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes 
  -std=gnu99 -Wimplicit-fallthrough -Wvla -fstack-protector-strong 
  -fdiagnostics-color=auto -Wno-array-bounds 

Features: +acl +iconv +jemalloc +tui 
See ":help feature-compile"
  • Must it happen automatically (nicer, but potentially hard to do) or can it be triggered manually (e.g. via a mapping/command; much easier, but requires an extra step)?
    – D. Ben Knoble
    Commented Dec 19, 2018 at 18:50
  • I'd like it to happen automatically. But your suggestions are welcome.
    – Bart
    Commented Dec 20, 2018 at 17:45
  • 1
    I also don't mind patching the source. It would be nice to have an equivalent to vim's termresponse mechanism. But it's perhaps more useful to be able automatically call a function when neovim receives SIGUSR1.
    – Bart
    Commented Dec 21, 2018 at 10:52
  • @Bart Adding a VimL event/autocmd for SIGUSR1 is a good idea, would you mind creating a ticket: github.com/neovim/neovim/issues Commented Jan 28, 2019 at 14:57
  • @JustinM.Keyes thanks, apparently the idea is received well: github.com/neovim/neovim/pull/9564
    – Bart
    Commented Feb 1, 2019 at 13:41

1 Answer 1


Since a new "Signal" autocmd was added, we can automatically call a function when neovim receives SIGUSR1. Which is nice.

$ readlink -qn ~/.config/termite/config

I now have this in my init.vim

" ~/.config/nvim/init.vim
" ...
au Main Signal * call Darkorlight('~/.config/termite/config')

function! Darkorlight(file) abort
  if getftype(expand(a:file)) != 'link'
  if resolve(glob(expand(a:file))) =~ '_dark$'
    set background=dark
    set background=light

I then watch for the symlink to change with this unit:

# ~/.config/systemd/user/termite.path
Description=Make termite reload its configuration file when it changes


# ~/.config/systemd/user/termite.service
Description=Send a signal to all termite and neovim processes

ExecStart=/usr/bin/killall -USR1 termite
ExecStart=/usr/bin/killall -USR1 nvim


This works great. It comes in handy as a toggle switch (i.e. for a toolbar):

if [[ `readlink $conf 2>/dev/null` =~ light ]]; then
  ln -sf "${conf}_dark" "$conf"
  ln -sf "${conf}_light" "$conf"

Thanks to Justin M. Keyes for encouraging me to ask for a scriptable Signal feature on Github, and to Marco Hinz for implementing it so quickly!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.