Skip to content

Instantly share code, notes, and snippets.

@roalcantara
Last active November 13, 2024 18:58
Show Gist options
  • Save roalcantara/107ba66dfa3b9d023ac9329e639bc58c to your computer and use it in GitHub Desktop.
Save roalcantara/107ba66dfa3b9d023ac9329e639bc58c to your computer and use it in GitHub Desktop.
XDG cheat sheet

XDG - Base Directory Specification

Directories

Base

The intended use-case for BaseDirectories is to query the paths of user-invisible standard directories that have been defined according to the conventions of the operating system the library is running on.

If you want to compute the location of cache, config or data folders for your own application or project, use ProjectDirectories instead.

User

The intended use-case for UserDirectories is to query the paths of user-facing standard directories that have been defined according to the conventions of the operating system the library is running on.

Project

The intended use-case for ProjectDirectories is to compute the location of cache, config or data folders for your own application or project, which are derived from the standard directories.

Correlations

Type Purpose XDG Environment Variable Linux / BSD MacOS
Base home HOME $HOME $HOME
Base cache XDG_CACHE_HOME $XDG_CACHE_HOME or $HOME/.cache $HOME/Library/Caches
Base config XDG_CONFIG_HOME $XDG_CONFIG_HOME or $HOME/.config $HOME/Library/Application Support
Base data XDG_DATA_HOME $XDG_DATA_HOME or $HOME/.local/share $HOME/Library/Application Support
Base dataLocal XDG_DATA_HOME $XDG_DATA_HOME or $HOME/.local/share $HOME/Library/Application Support
Base executable XDG_BIN_HOME $XDG_BIN_HOME or $HOME/.local/bin null
Base preference XDG_CONFIG_HOME $XDG_CONFIG_HOME or $HOME/.config $HOME/Library/Preferences
Base runtime XDG_RUNTIME_DIR $XDG_RUNTIME_DIR or null null
User audio XDG_MUSIC_DIR $XDG_MUSIC_DIR $HOME/Music
User desktop XDG_DESKTOP_DIR $XDG_DESKTOP_DIR $HOME/Desktop
User document XDG_DOCUMENTS_DIR $XDG_DOCUMENTS_DIR $HOME/Documents
User download XDG_DOWNLOAD_DIR $XDG_DOWNLOAD_DIR $HOME/Downloads
User font XDG_DATA_HOME $XDG_DATA_HOME/fonts or $HOME/.local/share/fonts $HOME/Library/Fonts
User picture XDG_PICTURES_DIR $XDG_PICTURES_DIR $HOME/Pictures
User public XDG_PUBLICSHARE_DIR $XDG_PUBLICSHARE_DIR $HOME/Public
User template XDG_TEMPLATES_DIR $XDG_TEMPLATES_DIR null
User video XDG_VIDEOS_DIR $XDG_VIDEOS_DIR $HOME/Movies
Project cache XDG_CACHE_HOME/<project_path> $XDG_CACHE_HOME or $HOME/.cache/<project_path> $HOME/Library/Caches/<project_path>
Project config XDG_CONFIG_HOME/<project_path> $XDG_CONFIG_HOME or $HOME/.config/<project_path> $HOME/Library/Preferences/<project_path>
Project data XDG_CONFIG_HOME/<project_path> $XDG_CONFIG_HOME or $HOME/.config/<project_path> $HOME/Library/Application Support/<project_path>
Project dataLocal XDG_DATA_HOME/<project_path> $XDG_DATA_HOME or $HOME/.local/share/<project_path> $HOME/Library/Application Support/<project_path>
Project preference XDG_DATA_HOME/<project_path> $XDG_DATA_HOME or $HOME/.local/share/<project_path> $HOME/Library/Application Support/<project_path>
Project runtime XDG_RUNTIME_DIR/<project_path> $XDG_RUNTIME_DIR/<project_path> null

source: https://github.com/dirs-dev/directories-jvm

@mattiasb
Copy link

mattiasb commented Nov 8, 2024

Note that several of these environment variables (like XDG_BIN_HOME) aren't in the spec at all.

@DavidPesticcio
Copy link

@mattiasb
Copy link

mattiasb commented Nov 13, 2024

ICYMI: https://specifications.freedesktop.org/basedir-spec/latest/

Thanks. I probably should've posted a link to the spec in my comment.

It seems like the confusion comes from this project FWIW: https://github.com/dirs-dev/directories-jvm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment