2021-02-18 22:25:36 +01:00
|
|
|
#include "fastfetch.h"
|
2022-07-25 13:15:01 +02:00
|
|
|
#include "common/printing.h"
|
2023-06-08 14:32:15 +08:00
|
|
|
#include "detection/theme/theme.h"
|
2021-02-18 22:25:36 +01:00
|
|
|
|
2021-04-15 18:59:26 +02:00
|
|
|
#define FF_THEME_MODULE_NAME "Theme"
|
2023-06-08 14:32:15 +08:00
|
|
|
#define FF_THEME_NUM_FORMAT_ARGS 1
|
2021-04-15 18:59:26 +02:00
|
|
|
|
2021-02-27 18:30:05 +01:00
|
|
|
void ffPrintTheme(FFinstance* instance)
|
2021-02-18 22:25:36 +01:00
|
|
|
{
|
2023-06-08 14:32:15 +08:00
|
|
|
FF_STRBUF_AUTO_DESTROY theme;
|
|
|
|
|
ffStrbufInit(&theme);
|
|
|
|
|
const char* error = ffDetectTheme(instance, &theme);
|
|
|
|
|
if (error)
|
2021-06-27 21:53:50 +02:00
|
|
|
{
|
2023-06-08 14:32:15 +08:00
|
|
|
ffPrintError(instance, FF_THEME_MODULE_NAME, 0, &instance->config.theme, "%s", error);
|
2021-06-27 21:53:50 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-17 18:15:36 +02:00
|
|
|
if(instance->config.theme.outputFormat.length == 0)
|
2021-03-19 20:57:07 +01:00
|
|
|
{
|
2022-06-17 18:15:36 +02:00
|
|
|
ffPrintLogoAndKey(instance, FF_THEME_MODULE_NAME, 0, &instance->config.theme.key);
|
2023-06-08 14:32:15 +08:00
|
|
|
ffStrbufPutTo(&theme, stdout);
|
2021-03-19 20:57:07 +01:00
|
|
|
}
|
2021-02-19 16:23:41 +01:00
|
|
|
else
|
2021-03-19 20:57:07 +01:00
|
|
|
{
|
2022-06-17 18:15:36 +02:00
|
|
|
ffPrintFormat(instance, FF_THEME_MODULE_NAME, 0, &instance->config.theme, FF_THEME_NUM_FORMAT_ARGS, (FFformatarg[]){
|
2023-06-08 14:32:15 +08:00
|
|
|
{FF_FORMAT_ARG_TYPE_STRBUF, &theme}
|
2021-04-15 18:59:26 +02:00
|
|
|
});
|
2021-03-19 20:57:07 +01:00
|
|
|
}
|
2021-03-27 18:14:19 +01:00
|
|
|
}
|