This code has not even been thought that hard about yet.
It involves this, though:
https://icculus.org/finger/icculus?date=2009-03-21§ion=otherstuff
Note that this was from before $XDG_DATA_HOME was a real thing. This repo is just here for history's sake and probably doesn't need a further thought.