Load, manage, and persist configuration settings
Source: target-root/usr/local/lib/solidgroundux/common/sgnd-cfg.sh
Load, manage, and persist configuration settings
Public functions
- Load the selected configuration file into shell variables.
- Persist a configuration variable and assign its current value.
- Remove a configuration key and unset its variable.
- Remove the active configuration file.
- Retrieve the persisted value of one configuration key.
- Check whether the active configuration contains a key.
- Display specified configuration keys and their effective stored values.
- Check whether a specification array contains an audience.
- sgnd_cfg_write_skeleton_filtered
- Load valid key/value lines from a readable config file.
- Create missing system and user configuration skeletons as permitted.
- Apply system then user configuration files for a domain.
- Load a state file into shell variables
- Persist a state key and update its shell variable
- Remove a persisted key and unset its variable
- Reset the selected state file
- Retrieve a persisted state value
- Check whether a state key is present
- Persist selected shell variables as state keys
- Restore selected persisted keys into shell variables
- List keys stored in a state file
Internal functions
| Function | Purpose | Arguments | Output |
|---|---|---|---|
_sgnd_lib_guard | Ensure direct execution is rejected and record that the library has been sourced. | — | — |
_sgnd_is_ident | Check whether text is a valid Bash variable identifier. | - $1 — Candidate identifier. | — |
_sgnd_kv_load_file | Read valid KEY=VALUE lines into variables in the current shell. | - $1 — Path of a key/value file. | — |
_sgnd_kv_set | Write or replace one key in a private key/value file. | - $1 — Destination file. | — |
_sgnd_kv_unset | Remove one key from a KEY=VALUE file. | - $1 — File path. | — |
_sgnd_kv_reset_file | Delete a key/value file if it exists. | - $1 — File path. | — |
_sgnd_kv_get | Read the first matching key from a readable KEY=VALUE file. | - $1 — File path. | Writes the exact value after the first equals sign without a trailing newline. |
_sgnd_kv_has | Test whether a valid key is present, including an empty value. | - $1 — File path. | — |
_sgnd_kv_list_keys | List identifier/value pairs from a readable configuration file. | - $1 — File path. | Writes one KEY\ |
_sgnd_cfg_write_template_header | Generate a comment header for a configuration template. | - $1 — Optional domain name (defaults to configuration). | Writes comment lines to standard output. |
Description
Provides configuration handling for the SolidGroundUX framework.
The library:
- Loads configuration from system and user locations
- Resolves effective configuration using precedence rules
- Supports reading and writing key-value configuration files
- Ensures required configuration values are present
- Provides helper functions for accessing configuration values
- Integrates with bootstrap and runtime state handling
Design principles
- Clear separation between system-level and user-level configuration
- Deterministic resolution of configuration values
- Minimal and transparent configuration format
- Safe defaults with optional overrides
Role in framework
- Central configuration layer used during bootstrap and runtime
- Supplies paths, settings, and environment-specific values
- Supports scripts and modules requiring persistent configuration
Non-goals
- Complex hierarchical configuration systems
- External configuration formats (JSON, YAML, etc.)
- Runtime hot-reloading of configuration
