JsonConfig: support "logo": null and "logo": "/path/to/logo"

This commit is contained in:
李通洲 2023-06-25 21:22:44 +08:00
parent 9021c6ee82
commit f0844d7636
No known key found for this signature in database
GPG Key ID: 6E72B663408769DE
5 changed files with 175 additions and 145 deletions

View File

@ -27,6 +27,16 @@
"format": "uri"
},
"logo": {
"oneOf": [
{
"title": "Disable logo",
"type": "null"
},
{
"title": "Set the source file of the logo",
"type": "string"
},
{
"title": "Fastfetch logo configurations",
"type": "object",
"properties": {
@ -183,6 +193,8 @@
}
},
"additionalProperties": false
}
]
},
"general": {
"title": "Fastfetch general configurations",

View File

@ -2,9 +2,7 @@
{
"$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json",
"logo": {
"source": "debian_small"
},
"logo": "debian_small",
"display": {
"binaryPrefix": "si"
},

View File

@ -2,9 +2,7 @@
{
"$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json",
"logo": {
"type": "none"
},
"logo": null,
"display": {
"color": "reset_magenta"
},

View File

@ -410,6 +410,12 @@ void ffLogoPrint(void)
const FFLogoOptions* options = &instance.config.logo;
if (options->type == FF_LOGO_TYPE_NONE)
{
logoPrintNone();
return;
}
//If the source is not set, we can directly print the detected logo.
if(options->source.length == 0)
{

View File

@ -201,6 +201,22 @@ const char* ffParseLogoJsonConfig(void)
yyjson_val* object = yyjson_obj_get(root, "logo");
if (!object) return NULL;
if (yyjson_is_null(object))
{
options->type = FF_LOGO_TYPE_NONE;
options->paddingTop = 0;
options->paddingRight = 0;
options->paddingLeft = 0;
return NULL;
}
if (yyjson_is_str(object))
{
const char* value = yyjson_get_str(object);
ffStrbufSetS(&options->source, value);
return NULL;
}
if (!yyjson_is_obj(object)) return "Property 'logo' must be an object";
yyjson_val *key_, *val;