Support the XDG-Basedir specification

Improvements related to #112. Sorry for the lack of feedback on #115 at the time, I had a lot of thing on me.

This adds no new dependencies whatsoever.