The Configuration Parsing System is responsible for loading, parsing, validating, and merging configuration data from multiple sources (JSONC/JSON5 files, command-line arguments, presets) into the application's internal configuration structures. This system bridges user-facing configuration formats to the internal option structures used by detection modules and output formatters.
The system is designed to handle a wide array of data types, from simple booleans to complex nested objects for module-specific behavior, while maintaining strict validation and helpful error reporting.
Sources: src/options/display.c10-14 src/options/display.h37-96 src/data/help.json88-125
The configuration system uses a hierarchical structure to organize settings. The primary container for display-related configuration is FFOptionsDisplay, while logo settings are managed via FFOptionsLogo.
Sources: src/options/display.h37-96 src/options/logo.c6-27 src/common/option.h57-65
Configuration data flows through a priority merging system where later sources override earlier ones. Command-line arguments hold the highest priority, followed by presets and user configuration files.
| Priority | Source | Mechanism |
|---|---|---|
| 1 (High) | CLI Arguments | ffOptionsParseLogoCommandLine, ffOptionsParseDisplayCommandLine |
| 2 | Preset Files | Loaded via --config <preset> |
| 3 | User Config | ~/.config/fastfetch/config.jsonc |
| 4 (Low) | Built-in Defaults | ffOptionsInitLogo, ffOptionsInitDisplay |
The system searches for configuration files in multiple directories. Presets can be listed via fastfetch --list-presets.
Sources: src/options/logo.c29-52 src/data/help.json38-41 src/data/help.json88-125
Fastfetch uses the yyjson library to parse configuration files. It supports JSONC (JSON with comments) by allowing non-standard JSON features during the read process.
Sources: src/options/display.c10-162 src/common/jsonconfig.h6-7 src/3rdparty/yyjson/yyjson.h91-98
CLI arguments are parsed iteratively. The system uses prefix testing to route arguments to the correct subsystem (e.g., logo-, display-).
Sources: src/options/logo.c29-131 src/common/option.h73-84
The FFOptionsDisplay structure contains global formatting settings that affect all modules.
| Category | Field in Code | JSON Key | Type |
|---|---|---|---|
| Separators | keyValueSeparator | separator | FFstrbuf |
| Error Handling | showErrors | showErrors | bool |
| Size Units | sizeBinaryPrefix | size.binaryPrefix | FFSizeBinaryPrefixType |
| Temperature | tempUnit | temp.unit | FFTemperatureUnit |
| Progress Bars | barWidth | bar.width | uint8_t |
Sources: src/options/display.h37-96 src/options/display.c48-162
Modules are defined in the modules array within the JSON configuration. Each entry can be a simple string (shorthand) or a complex object.
The system has removed direct CLI support for module-specific options. Users attempting to use them receive a migration error pointing to the JSON configuration.
Sources: src/common/impl/commandoption.c13-67 src/common/option.h24-40
To assist users in creating valid configurations, fastfetch provides a JSON Schema and embedded help data.
doc/json_schema.json, it defines the structure, types (like colors, percentType), and constraints for every configuration option.src/data/help.json, this is used to generate the --help output. It categorizes options into groups like Informative, Config, General, and Logo.Sources: doc/json_schema.json1-155 src/data/help.json1-182
| Function | File | Description |
|---|---|---|
ffOptionsParseDisplayJsonConfig | src/options/display.c10 | Entry point for parsing the display object in JSON. |
ffOptionsParseLogoCommandLine | src/options/logo.c29 | Entry point for parsing --logo-* CLI arguments. |
ffJsonConfigParseEnum | src/common/impl/jsonconfig.c | Helper to map JSON strings to internal C enums using FFKeyValuePair. |
ffOptionTestPrefix | src/common/option.h73 | Checks if a CLI argument starts with a specific module/category prefix. |
ffParseModuleOptions | src/common/impl/commandoption.c13 | Legacy CLI module option handler that now triggers migration errors. |
The system uses a bitmask-based approach for percentage types, allowing users to combine numbers and bars via FFPercentageTypeFlags.
Sources: src/common/percent.h7-17 src/options/display.h79 doc/json_schema.json42-71
Refresh this wiki