Significantly reduce code duplication for XDG_CONFIG_HOME support