xdgtools - XDG Specifications fun

Functions for working with xdg paths and environment.

The setenv() function sets all XDG single directory environment variables to their values. It is also called on module instantiation.

torxtools.xdgtools.setenv() None

XDG Base Directory Specification environment variables setter.

Sets all XDG environment variables (XDG_CACHE_HOME, XDG_CONFIG_HOME, XDG_DATA_HOME, XDG_CONFIG_DIRS, XDG_DATA_DIRS, and XDG_RUNTIME_DIR) to their respective values according to current os.environ or their defaults.

All paths will be expanded before being set.

Example

from torxtools import xdgtools, pathtools

try:
    del os.environ["XDG_CONFIG_HOME"]
except:
    pass
# We changed the XDG environment:
xdgtools.setenv()
assert os.environ["XDG_CONFIG_HOME"] == pathtools.expandpath("$HOME/.config")