-
-
Notifications
You must be signed in to change notification settings - Fork 899
Logo
Query built-in logo for JSON output
| Module type | logo |
| Default order | — (no defaultOrder) |
| Module source | src/modules/logo/logo.c |
| Detection source | — (reads the logo tables in src/logo/) |
Exports the built-in ASCII logo that fastfetch would draw, as JSON, so that another program can render it. It has no console output at all:
Logo: Supported in JSON format only
The module exists to answer “what is the logo of the detected system, and what are its color placeholders?” from a script.
| Platform | Implementation | Notes |
|---|---|---|
| Everywhere |
src/logo/ascii/*.inc, src/logo/logo.c
|
Platform independent |
No detection layer. Which logo is exported depends only on the logo.source / logo.type settings
(see below), not on the compiling platform.
| Option | Type | Default | Description |
|---|---|---|---|
condition |
object | – | See Configuration. |
That is the only option the module's JSON parser accepts. type is silently ignored (the module
has no per-module type setting of its own). The logo to export is chosen by the global logo
settings, not by module options:
| Setting | Values | Meaning |
|---|---|---|
logo.type |
auto, builtin, small, … |
Which kind of logo to export. Only auto, builtin and small are exportable; anything else is an error. |
logo.source |
a logo name | Export this specific logo by name (e.g. ubuntu, debian, macOS_small). Empty means “the detected one”. |
Both are global, so they apply to the whole run:
None. The module has no key and no format string.
{
"type": "Logo",
"result": {
"lines": " ..'\n ,xNMM.\n .OMMMMo\n ...",
"names": [ "macOS" ],
"colors": [ "32", "33", "91", "31", "35", "34" ],
"colorKeys": "33",
"colorTitle": "32",
"type": [ "normal" ]
}
}| Field | Meaning |
|---|---|
lines |
The logo art. \n separates rows. $1 … $9 are placeholders for colors[0] … colors[8]. |
names |
All names this logo answers to. The first is the canonical one. |
colors |
ANSI SGR parameters (without the \e[ … m wrapper) for the $N placeholders. |
colorKeys |
SGR parameter for the module keys next to the logo. |
colorTitle |
SGR parameter for the title line. |
type |
Which variants of the logo this entry describes. See Pitfalls. |
Failures are reported as error and no result:
{ "type": "Logo", "error": "No built-in logo found for the specified name/size" }
{ "type": "Logo", "error": "Only 'builtin' and 'small' logo types are supported" }The detected system's logo:
{ "modules": [ "logo" ] }A specific distribution's logo, whatever OS you are on:
{ "logo": { "source": "ubuntu" }, "modules": [ "logo" ] }The small variant:
{ "logo": { "type": "small" }, "modules": [ "logo" ] }-
The module never prints to the console. Running
fastfetch -s logoonly showsSupported in JSON format only. It is meaningful only with--format json. -
--logo <value>takes a logo name, not a type. Onlynoneandsmallare recognised specially; every other value is stored as the logo source. So--logo autoasks for a built-in logo literally namedautoand fails withNo built-in logo found for the specified name/size— even thoughautois a valid type. Use--logo-type auto/--logo-type builtinto change the type. The same trap applies to--logo chafa,--logo sixel,--logo iterm,--logo rawand friends. -
typedescribes the variant, and a regular logo reports["normal"].NORMALis0, so it cannot be tested with&; the module compares against it instead. The other two entries are bit tests, so they combine:{ "logo": { "source": "Alpine2" } } // -> "type": [ "alter" ] { "logo": { "source": "alpine2_small" } } // -> "type": [ "small", "alter" ] -
--logo noneis an error, not an empty result. The module rejects thenonetype withOnly 'builtin' and 'small' logo types are supportedinstead of returning an empty logo. -
linesis raw art, not terminal output. Color placeholders are not substituted — the JSON gives you$1and leaves the mapping to you. The art also assumes a Nerd Font only for the icon of a builtin image; the ASCII art itself is plain. -
colorKeys/colorTitleare SGR fragments. Insert them as\e[<value>m; they are not full escape sequences and there is no reset in them. -
type: "small"does not derive a small variant — it selects one by name. The small art of a distribution is registered as its own entry (alpine2_small, not a scaledAlpine2), so{ "logo": { "type": "small", "source": "Alpine2" } }fails withNo built-in logo found for the specified name/size. Omittypeand let the name pick the art.
ffPrintLogo() does nothing but report the error — the console path is
deliberately unimplemented.
All the work is in ffGenerateLogoJsonResult():
-
Map the global
logo.typeonto anFFLogoSize:FF_LOGO_TYPE_SMALL→FF_LOGO_SIZE_SMALL; anything that is notFF_LOGO_TYPE_BUILTINand notFF_LOGO_TYPE_AUTO→ error out. -
Look the logo up:
-
logo.sourcenon-empty →ffLogoGetBuiltinForName(&source, size) - otherwise →
ffLogoGetBuiltinDetected(size)
A miss returns
No built-in logo found for the specified name/size. -
-
Emit the fields.
names,colorsandtypeare arrays; the loops stop at theFASTFETCH_LOGO_MAX_NAMES/FASTFETCH_LOGO_MAX_COLORSsentinels (nullptr).
The type array is built by two bit tests and one comparison:
if (logo->type == FF_LOGO_LINE_TYPE_NORMAL) yyjson_mut_arr_add_str(doc, typeArr, "normal");
if (logo->type & FF_LOGO_LINE_TYPE_SMALL_BIT) yyjson_mut_arr_add_str(doc, typeArr, "small");
if (logo->type & FF_LOGO_LINE_TYPE_ALTER_BIT) yyjson_mut_arr_add_str(doc, typeArr, "alter");NORMAL is 0 (src/logo/logo.h), so a bit test for it can never be true — the equality comparison
is what makes a regular logo report "normal" instead of an empty array. The other two are genuine
bits, which is why they can appear together.
Note that the module's parseJsonObject swallows type and condition and routes everything else
through ffPrintError(), so an unknown key here is silent unless display.showErrors is enabled.
{ "logo": { "source": "debian" }, "modules": [ "logo" ] }