Skip to content

Colors: fixes --gen-config writing the default background symbol as block - #2784

Open
farisbasha wants to merge 1 commit into
fastfetch-cli:devfrom
farisbasha:fix/colors-genconfig-background
Open

farisbasha wants to merge 1 commit into
fastfetch-cli:devfrom
farisbasha:fix/colors-genconfig-background

Conversation

@farisbasha

@farisbasha farisbasha commented Dec 5, 2026 •

Copy link
Copy Markdown

Summary

The Colors module's default symbol is background, but ffGenerateColorsJsonConfig() has no case for FF_COLORS_SYMBOL_BACKGROUND, so it falls through to default: and writes "block". A full config from --gen-config (the o toggle) therefore changes how the palette is printed: background-colored cells become foreground ███ runs.

Repro (Linux):

echo '{"modules":["colors"]}' > def.jsonc
fastfetch -c def.jsonc --gen-config gen.jsonc   # press o (full), then s
grep '"symbol"' gen.jsonc                       # "symbol": "block"
fastfetch -c def.jsonc -l none -s colors        # \e[40m   \e[41m   ...
fastfetch -c gen.jsonc -l none -s colors        # \e[30m███\e[31m███ ...

I found this with a round-trip check over doc/json_schema.json: set each enum/bool option, generate a full config, and compare what comes back. background was the only value that did not survive. The others that differed were aliases, such as both-1 written as both.

Related issue (required for new logos for new distros)

None. This is a small bug fix.

Changes

  • Colors: add the missing FF_COLORS_SYMBOL_BACKGROUND case to ffGenerateColorsJsonConfig().
  • New tests/colors.c (test-colors). It checks that the default options generate "background", and that every symbol is written under its own name and parsed back to the same value. It fails on dev (default symbol: expected "background", got "block") and passes with the fix.
  • CHANGELOG entry under Bugfixes.

Run on a Linux x86_64 server (Debug build, zig cc / clang, -DBUILD_TESTS=ON):

  • ctest --output-on-failure: 21/22 pass, including the new test-colors. The failing one is test-base64: with this toolchain it hits a UBSan trap on the unaligned uint32_t load in src/common/impl/base64.c, a file this PR does not touch.
  • ./build/fastfetch -c presets/all.jsonc --stat false and ./build/fastfetch --format json both exit 0.
  • The repro above now gives "symbol": "background", and both configs print the same palette.
  • clang-format 23 has no complaints about the lines changed in colors.c. In the new tests/colors.c it flags the three long fprintf(stderr, ...) lines, the same pattern it flags in tests/percent.c.

Screenshots

Not a visual change in fastfetch itself. A generated config now prints the same as the default one.

Checklist

  • I have tested my changes locally.

This PR was prepared with AI assistance (Claude).

…as `block`

ffGenerateColorsJsonConfig() had no case for FF_COLORS_SYMBOL_BACKGROUND, so the
default symbol fell through to "block". A full config from --gen-config therefore
printed the palette as foreground blocks instead of background cells.

Adds the missing case and a test that generates the config for every symbol and
reads it back.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant