# The new config system in pcb-rnd

## Sources

There are different sources of configuration settings. These are different configuration files, sometimes located on the file system. The full list of config sources is:

role | default setting prio | location | presence | remarks
--- | --- | --- | --- | ---
internal | 100 | (compiled into the executable) | always | the ultimate fallback; allows pcb-rnd even if no other configuration file is found
system | 200 | /usr/share/pcb-rnd/pcb-conf.lht | recommended | should hold system and installation specific settings, e.g. path to the system-wise installed footprint library
default board | 300 | /usr/share/pcb-rnd/default4.lht1 | deprecated2 | pcb editable defaults
user | 400 | ~/.pcb-rnd/pcb-conf.lht | recommended | store user preferences, user's common footprint lib path, etc; this is the first file the user can modify (even from the GUI)
environment | 500 | environment variables (TODO) | occasional | inject the same (temporary) settings in multiple pcb-rnd sessions without having to change config files
project | 600 | project.lht in the project directory | optional | local project settings - useful for large projects with multiple board (.lht) files
design | 700 | saved in the board (.lht) file | optional, common | per design deviation from the user+system config
cli | 800 | command line argument | occasional | inject/change a setting for a single session; useful in batch/automated processing

Pcb-rnd reads them all, then merges all settings into a master binary representation. If a setting is specified in multiple sources, the one with the higher priority wins, except for lists where it is also possible to prepend/append items. Default priorities are designed to result precedence in an intuitive way (e.g. design settings overwrite user settings). However, priority can be changed per setting, resulting in weak settings ("use this value if it was not already set") or strong settings ("I always want to use mincut, so I enable it from my user's config with high priority and a version controlled project setting can not turn it off")

Footnotes:

- 1: the name of the default board is default4.lht for the default 4 layer board. The standard installation also ships default2.lht as a similar 2 layer board. The name of the default baordfile is configured in config node rc/default_pcb_file.
- 2: default pcb should not contain a config subtree; it is easier to maintain the config tree if default configuration is coming from config files only.