Questions

Elsie Hupp xdg at elsiehupp.com
Sat Nov 20 19:15:24 UTC 2021


Hi Jérôme,

The Arch Wiki has a pretty good guide to the `xdg-user-dirs` package installed on most Linux distributions:

https://wiki.archlinux.org/title/XDG_user_directories

I’ve dug around in the boilerplate code for *looking up* `xdg-user-dirs`, and it basically queries `XDG_FOOBAR_DIR` for `FOOBAR`, so you *should* basically be able to define any custom folder you want. You can check out my pending pull request on `pyxdg` for a version of the code that’s somewhat easier to read than the original C:

https://gitlab.freedesktop.org/xdg/pyxdg/-/merge_requests/13

The actual Python file:

https://gitlab.freedesktop.org/xdg/pyxdg/-/blob/8fa45fbbe4cd6676b388ca0549f875739301ed21/xdg/UserDirectory.py

Note that this is a simplified line-by-line translation of `xdg-user-dir-lookup`:

https://gitlab.freedesktop.org/xdg/xdg-user-dirs/-/blob/master/xdg-user-dir-lookup.c

However, a big part of the functionality behind `xdg-user-dirs` is (a) the basic list is standardized across most Linux distros, and (b) the actual name of the directory is localized into a large number of natural languages.

The main reason actually that I joined this mailing list was to ask about directories for difficult-to-categorize use cases, like ebooks or podcasts (or code repositories or, yes, games).

So, hypothetically, yes, you could define your own `xdg-user-dirs`. However, `xdg-user-dirs` is a tool rather than standard, and even if you got a pull request approved for some additional directory, it would probably take years to percolate out through the install base and never actually reach 100% of users. Oh, and you’d also need to get it adopted by both GLib and Qt. (Qt would probably be easier, considering Windows does IIRC have a `My Games` directory, so there’s already a cross-platform precedent.)

This is to say that if you define your own custom directories in `xdg-user-dirs` in application code, you should always define a fallback. And in some respects `xdg-user-dirs` is kind of falling out of fashion with the rise in Flatpak and Snap for end-user applications, where each application basically just has its own sandboxed home folder, rather than using a shared per-content-type directory, even though Flatpak portals do increasingly support arbitrary locations in userspace.

Anyway, I hope this is helpful!

Best,
Elsie Hupp

> On Nov 19, 2021, at 3:51 PM, Jérôme Bardot <bardot.jerome at gmail.com> wrote:
> 
> Hello,
> 
> There is a way to to add this own stuff in XDG_CONFIG_HOME/user-dirs.dirs ? I want a XDG_GAMES_DIR=
> 
> Also can i access to XDG var from a shell ? 
> 
> thx 
> 
> More specifically someone can mentor me to push stuff if needed ? 
> 



More information about the xdg mailing list