package xdg-basedir

  1. Overview
  2. Docs
Module type
Class type

XDG basedir implementation

The XDG basedir specification makes clear where to store configuration, cache and data files. This a way to maintain a clean $HOME. Locations can be customized through environment variables (XDG_DATA_HOME, XDG_CONFIG_HOME). It also allows to store files in several places (i.e. system directories).

  • author Sylvain Le Gall


type filename = string
type dirname = string
type dirnames = dirname list
type t = {
  1. data_home : dirname;


  2. data_dirs : dirnames;


  3. config_home : dirname;


  4. config_dirs : dirnames;


  5. cache_home : dirname;



XDG environment

Modules and functions

val default : t

Default XDG environment

val mkdir_openfile : (filename -> 'a) -> filename -> 'a

mkdir_openfile f fn Create parent directory of fn and apply f fn

module Data : sig ... end

In this module, ~xdg_env allows to override the default XDG environment. If you use ~exists:true, the files/dirs are tested for existence.

module Config : sig ... end

See Data for explanations about ~xdg_env and ~exists

module Cache : sig ... end

See Data for explanations about ~xdg_env and ~exists


Innovation. Community. Security.