Probably via OSC 10/11 or similar.
Use case: user switches theme on the fly (well-supported in GTK3/4, QT5/6, vim/neovim, many terminal emulators, etc).
OSC 10/11
It requires processing terminal's response. Vifm never does this right now, curses is handling all input and I don't think it distinguishes such responses from normal input. However, a sychronous request/response may be possible (needs to be tried).
I’m not sure how you switch between light and dark themes, but if you are able to set an environment variable while doing so, you could add the following to your Vifm config:
if $IS_DARK_THEME == '1' colorscheme Default else colorscheme dwmlight endif
Ended up with:
let $theme_state = system('cat "' . $HOME.'/.cache/theme_state' . '" | tr -d "\n"') if $theme_state == 'dark' colorscheme dark else colorscheme dark endif
Works like a charm!