One more question/idea - how hard would it be to just check for a userid of 0, but a home directory of [not /root]? And in that case, just go ahead and use whatever $HOME says, but add "_root_" somewhere in the name (or something like that)? I mean, I get it that sudo is broken in that regard. But it will probably never be "fixed" because too much relies on it's very specific behavior. So why not just work with it? There's quite a bit that can be known about the environment we're running in and how we got there. Why not use it, to address the problem of propagating a very well-known and understood bug in a lower level, up to higher-level users?
Granted I'm probably mixing up the specific locations you use. (I actually recall the "domain socket" files existing in /tmp, not /home/user. But the same concept would apply.)
This would give you a predictable starting location and name, while also allowing geany users to not be inconvenienced by the very inconsiderate sudo bug. I know for a fact from Google that I'm not the only user that experiences this, but even if it were - say, five users, and the fix was literally a 15 minute change to a few lines plus some testing...wouldn't that be satisfying?