class

XdgBaseDirectory::XdgDirs

Inherits Reference < Object

XdgDirs is a helper class to quickly access all the xdg-directories for a certain application.

Usage:

xdg_dirs = XdgDirs.new("my-awesome-app")
settings = xdg_dirs.config.read_file("settings.ini")
# ...

Constructors

new(*subdirs : String)

This class assumes that all files live in subdirectories of the XDG base dirs.

Source

Instance methods

all_config_dirs

xdg_config_home + xdg_config_dirs as XdgDirs

The order of base directories denotes their importance; the first directory listed is the most important. When the same information is defined in multiple places the information defined relative to the more important base directory takes precedent. The base directory defined by $XDG_DATA_HOME is considered more important than any of the base directories defined by $XDG_DATA_DIRS. The base directory defined by $XDG_CONFIG_HOME is considered more important than any of the base directories defined by $XDG_CONFIG_DIRS.

Source
all_data_dirs

xdg_data_home + xdg_data_dirs as XdgDirs

The order of base directories denotes their importance; the first directory listed is the most important. When the same information is defined in multiple places the information defined relative to the more important base directory takes precedent. The base directory defined by $XDG_DATA_HOME is considered more important than any of the base directories defined by $XDG_DATA_DIRS. The base directory defined by $XDG_CONFIG_HOME is considered more important than any of the base directories defined by $XDG_CONFIG_DIRS.

Source
cache

A directory to which user-specific non-essential (cached) data should be written.

Source
config

A directory to which user-specific configuration files should be written.

Source
config_files(filename)

Look up configuration files by filename in all config dirs in order of importance.

A specification that refers to $XDG_DATA_DIRS or $XDG_CONFIG_DIRS should define what the behaviour must be when a file is located under multiple base directories. It could, for example, define that only the file under the most important base directory should be used or, as another example, it could define rules for merging the information from the different files.

Source
data

A directory to which user-specific data files should be written.

Source
data_files(filename)

Look up data files by filename in all data dirs in order of importance.

A specification that refers to $XDG_DATA_DIRS or $XDG_CONFIG_DIRS should define what the behaviour must be when a file is located under multiple base directories. It could, for example, define that only the file under the most important base directory should be used or, as another example, it could define rules for merging the information from the different files.

Source
runtime_dir

A directory in which user-specific runtime files and other file objects should be placed.

Source
state

state data that should persist between (application) restarts, but that is not important or portable enough to the user that it should be stored in data_home

Source

Macros

def_xdg_dir(name, method_name = "")

define a method to return the specified XdgDir for this application.

Source