mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-12 10:22:12 +02:00
WMTheme: support JSON format
This commit is contained in:
@@ -32,7 +32,7 @@ void ffPrintWMTheme(FFWMThemeOptions* options)
|
||||
|
||||
void ffInitWMThemeOptions(FFWMThemeOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(&options->moduleInfo, FF_WMTHEME_MODULE_NAME, ffParseWMThemeCommandOptions, ffParseWMThemeJsonObject, ffPrintWMTheme, NULL);
|
||||
ffOptionInitModuleBaseInfo(&options->moduleInfo, FF_WMTHEME_MODULE_NAME, ffParseWMThemeCommandOptions, ffParseWMThemeJsonObject, ffPrintWMTheme, ffGenerateWMThemeJson);
|
||||
ffOptionInitModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
@@ -67,3 +67,15 @@ void ffParseWMThemeJsonObject(FFWMThemeOptions* options, yyjson_val* module)
|
||||
ffPrintError(FF_WMTHEME_DISPLAY_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
void ffGenerateWMThemeJson(FF_MAYBE_UNUSED FFWMThemeOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module)
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY themeOrError = ffStrbufCreate();
|
||||
if(!ffDetectWmTheme(&themeOrError))
|
||||
{
|
||||
yyjson_mut_obj_add_strbuf(doc, module, "error", &themeOrError);
|
||||
return;
|
||||
}
|
||||
|
||||
yyjson_mut_obj_add_strbuf(doc, module, "result", &themeOrError);
|
||||
}
|
||||
|
||||
@@ -9,3 +9,4 @@ void ffInitWMThemeOptions(FFWMThemeOptions* options);
|
||||
bool ffParseWMThemeCommandOptions(FFWMThemeOptions* options, const char* key, const char* value);
|
||||
void ffDestroyWMThemeOptions(FFWMThemeOptions* options);
|
||||
void ffParseWMThemeJsonObject(FFWMThemeOptions* options, yyjson_val* module);
|
||||
void ffGenerateWMThemeJson(FFWMThemeOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module);
|
||||
|
||||
Reference in New Issue
Block a user