@yparitcher: The neat way would be to punt the nightmode handling to the kernel by
just flipping the grayscale flag in the fb state instead of ORing the INVERT EPDC flag on each refresh ourselves. This way *every* refresh is inverted, no matter the source.
This is highly platform specific, though (mxcfb @ 8bpp, which, granted, means the full Kobo lineup, the full reMarkable lineup, and every Kindle on FW 5.x. And possibly PB, too).
----
The cheap way would be to simply check the process table for luajit/koreader and skip the fbink_refresh() call if it's up

.
AFAIR, it's a bit gnarly if you want to do it in C, because you're basically reinventing procps, so it may be simpler to just rely on the output from pidof or pgrep.