Skip to content

getXdgBaseDirectories

getXdgBaseDirectories(options?): XdgBaseDirectories

Defined in: packages/app-system/src/os/xdg-base-directories.ts:69

Resolves the XDG base directories (specification 0.8): where an application should read and write its data, configuration, state, cache and runtime files on Linux and other freedesktop.org systems.

Append the application’s own directory name to the one it needs: join(getXdgBaseDirectories().dataHome, "myapp"). Nothing is created.

A variable that is unset, empty or holds a relative path falls back to its default, as the specification requires; in a list, relative entries are dropped, and a list left empty falls back too.

Time complexity: O(n) in the length of the variables read. Memory: O(n).

GetXdgBaseDirectoriesOptions

The environment and home directory to read.

XdgBaseDirectories

The directories, as absolute paths.

getXdgBaseDirectories({ env: {}, home: "/home/ada" }).dataHome;
// "/home/ada/.local/share"