Expand description
§xdge
A complete, zero-dependency implementation of the XDG Base Directory Specification v0.8 for Linux and Unix systems.
§Quick Start
use xdge::XdgDirs;
let xdg = XdgDirs::new();
// Where to write user config
println!("{}", xdg.config_home().display()); // e.g. /home/alice/.config
// Where to write user data
println!("{}", xdg.data_home().display()); // e.g. /home/alice/.local/share
// Search all config dirs for "myapp/settings.toml"
if let Some(path) = xdg.find_config_file("myapp/settings.toml") {
println!("Found config at {}", path.display());
}§XDG Variables Implemented
| Variable | Default | Method |
|---|---|---|
$XDG_DATA_HOME | $HOME/.local/share | XdgDirs::data_home |
$XDG_CONFIG_HOME | $HOME/.config | XdgDirs::config_home |
$XDG_STATE_HOME | $HOME/.local/state | XdgDirs::state_home |
$XDG_CACHE_HOME | $HOME/.cache | XdgDirs::cache_home |
$XDG_RUNTIME_DIR | (none — warn if unset) | XdgDirs::runtime_dir |
$XDG_DATA_DIRS | /usr/local/share:/usr/share | XdgDirs::data_dirs |
$XDG_CONFIG_DIRS | /etc/xdg | XdgDirs::config_dirs |
| (user bin) | $HOME/.local/bin | XdgDirs::user_bin_dir |
Structs§
- XdgDirs
- Resolved XDG Base Directory paths.
Enums§
- XdgError
- Errors that can be returned by directory-creation helpers.