Expand description
The XDG user directories — Documents, Downloads, Pictures, Music,
Videos, Desktop — read from ~/.config/user-dirs.dirs rather than
hardcoded, so a sidebar built on a machine set up in another language
shows that language’s own folder names instead of a translated set of
English guesses sitting next to directories that don’t exist.
xdg-user-dirs-update writes lines like:
XDG_DOCUMENTS_DIR="$HOME/Dokumente"— one KEY="value" pair per line, $HOME a literal prefix to be
substituted, #-comments and blank lines allowed anywhere. This
parses exactly that shape and nothing more: no shell expansion beyond
the one $HOME substitution the format actually uses, because a
general shell parser is a dependency this crate does not need for a
file with eight fixed keys.
Here rather than in hyprforge-files-core, where it started, because
the photo viewer’s sidebar needs Pictures and Downloads too, and the
alternatives were a dependency on the whole file browser or a second
parser. hyprforge-files-core re-exports it as xdg_user_dirs.
Structs§
- User
Dirs - The subset of XDG user directories a sidebar cares about.
Nonefor a directory the file doesn’t mention — a partially customised file is common (someone deletes theXDG_TEMPLATES_DIRline and nothing else), and a missing key is not this module’s business to guess at; a sidebar built from it simply won’t offer a shortcut for it.
Functions§
- fallback
- The conventional English names, used only when there is no
user-dirs.dirsto read at all (seeload). A sidebar still checks each of these against the real filesystem before offering it, so a guess that doesn’t exist on this machine is dropped rather than shown as a dead shortcut. - load
- Reads and parses
user-dirs.dirsfrom the config directory, or falls back to the conventional English names underhomeif the file isn’t there. - parse
- Parses the contents of a
user-dirs.dirsfile.homeis substituted for a leading$HOMEin each value, matching howxdg-user-dirsitself writes the file.