That looks like an interesting little problem,. I don’t have time to play with it (too busy bashing Leftists), but if you haven’t solved it yet, you might consider trying copum.nix.shell. They’re usually helpful — although some yahoo will problem tell you to RTFM.