mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-31 10:02:49 +01:00
Wallpaper: support JSON format
This commit is contained in:
@@ -44,7 +44,7 @@ void ffPrintWallpaper(FFWallpaperOptions* options)
|
||||
|
||||
void ffInitWallpaperOptions(FFWallpaperOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(&options->moduleInfo, FF_WALLPAPER_MODULE_NAME, ffParseWallpaperCommandOptions, ffParseWallpaperJsonObject, ffPrintWallpaper, NULL);
|
||||
ffOptionInitModuleBaseInfo(&options->moduleInfo, FF_WALLPAPER_MODULE_NAME, ffParseWallpaperCommandOptions, ffParseWallpaperJsonObject, ffPrintWallpaper, ffGenerateWallpaperJson);
|
||||
ffOptionInitModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
@@ -79,3 +79,15 @@ void ffParseWallpaperJsonObject(FFWallpaperOptions* options, yyjson_val* module)
|
||||
ffPrintError(FF_WALLPAPER_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
void ffGenerateWallpaperJson(FF_MAYBE_UNUSED FFWallpaperOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module)
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY fullpath = ffStrbufCreate();
|
||||
const char* error = ffDetectWallpaper(&fullpath);
|
||||
if(error)
|
||||
{
|
||||
yyjson_mut_obj_add_str(doc, module, "error", error);
|
||||
return;
|
||||
}
|
||||
yyjson_mut_obj_add_strbuf(doc, module, "result", &fullpath);
|
||||
}
|
||||
|
||||
@@ -9,3 +9,4 @@ void ffInitWallpaperOptions(FFWallpaperOptions* options);
|
||||
bool ffParseWallpaperCommandOptions(FFWallpaperOptions* options, const char* key, const char* value);
|
||||
void ffDestroyWallpaperOptions(FFWallpaperOptions* options);
|
||||
void ffParseWallpaperJsonObject(FFWallpaperOptions* options, yyjson_val* module);
|
||||
void ffGenerateWallpaperJson(FFWallpaperOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module);
|
||||
|
||||
Reference in New Issue
Block a user