I came across stderred a few months ago while looking to do the same thing on my terminals. I ultimately didn't go with it because people have reported destroying their systems while using it[1]. Wrapping libc (which is itself wrapping the actual syscall) is a tricky thing to do safely.
I looked into accomplishing the same thing with URxvt's pre- and post-text rendering hooks, but couldn't get it to work.