Files
fastfetch/src/modules/theme.c
T

80 lines
3.2 KiB
C
Raw Normal View History

2021-02-18 22:25:36 +01:00
#include "fastfetch.h"
2021-04-15 18:59:26 +02:00
#define FF_THEME_MODULE_NAME "Theme"
#define FF_THEME_NUM_FORMAT_ARGS 7
2021-02-27 18:30:05 +01:00
void ffPrintTheme(FFinstance* instance)
2021-02-18 22:25:36 +01:00
{
2021-04-16 20:22:38 +02:00
ffCalculatePlasmaAndGtk(instance);
2021-03-27 18:14:19 +01:00
2021-04-16 20:22:38 +02:00
if(instance->state.plasma.widgetStyle.length == 0 && instance->state.plasma.colorScheme.length == 0 && instance->state.gtk2.theme.length == 0 && instance->state.gtk3.theme.length == 0 && instance->state.gtk4.theme.length == 0)
2021-04-05 19:25:34 +02:00
{
2021-04-15 18:59:26 +02:00
ffPrintError(instance, FF_THEME_MODULE_NAME, 0, &instance->config.themeKey, &instance->config.themeFormat, FF_THEME_NUM_FORMAT_ARGS, "No themes found");
2021-04-05 19:25:34 +02:00
return;
}
2021-03-19 20:57:07 +01:00
2021-04-09 19:21:56 +02:00
FF_STRBUF_CREATE(plasmaColorPretty);
2021-04-16 20:22:38 +02:00
if(ffStrbufStartsWithIgnCase(&instance->state.plasma.colorScheme, &instance->state.plasma.widgetStyle))
ffStrbufAppendNS(&plasmaColorPretty, instance->state.plasma.colorScheme.length - instance->state.plasma.widgetStyle.length, &instance->state.plasma.colorScheme.chars[instance->state.plasma.widgetStyle.length]);
2021-04-09 19:21:56 +02:00
else
2021-04-16 20:22:38 +02:00
ffStrbufAppend(&plasmaColorPretty, &instance->state.plasma.colorScheme);
2021-04-09 19:21:56 +02:00
ffStrbufTrim(&plasmaColorPretty, ' ');
FF_STRBUF_CREATE(gtkPretty);
2021-04-16 20:22:38 +02:00
ffGetGtkPretty(&gtkPretty, &instance->state.gtk2.theme, &instance->state.gtk3.theme, &instance->state.gtk4.theme);
2021-03-19 20:57:07 +01:00
2021-03-23 19:48:52 +01:00
if(instance->config.themeFormat.length == 0)
2021-03-19 20:57:07 +01:00
{
2021-04-15 18:59:26 +02:00
ffPrintLogoAndKey(instance, FF_THEME_MODULE_NAME, 0, &instance->config.themeKey);
2021-04-16 20:22:38 +02:00
if(instance->state.plasma.widgetStyle.length > 0)
2021-04-09 19:21:56 +02:00
{
2021-04-16 20:22:38 +02:00
ffStrbufWriteTo(&instance->state.plasma.widgetStyle, stdout);
2021-04-09 19:21:56 +02:00
2021-04-16 20:22:38 +02:00
if(instance->state.plasma.colorScheme.length > 0)
2021-04-09 19:21:56 +02:00
{
fputs(" (", stdout);
if(plasmaColorPretty.length > 0)
ffStrbufWriteTo(&plasmaColorPretty, stdout);
else
2021-04-16 20:22:38 +02:00
ffStrbufWriteTo(&instance->state.plasma.colorScheme, stdout);
2021-04-09 19:21:56 +02:00
putchar(')');
}
}
2021-04-16 20:22:38 +02:00
else if(instance->state.plasma.colorScheme.length > 0)
2021-04-09 19:21:56 +02:00
{
if(plasmaColorPretty.length > 0)
ffStrbufWriteTo(&plasmaColorPretty, stdout);
else
2021-04-16 20:22:38 +02:00
ffStrbufWriteTo(&instance->state.plasma.colorScheme, stdout);
2021-04-09 19:21:56 +02:00
}
2021-04-16 20:22:38 +02:00
if(instance->state.plasma.widgetStyle.length > 0 || instance->state.plasma.colorScheme.length > 0)
2021-04-07 12:55:11 +02:00
{
fputs(" [Plasma]", stdout);
if(gtkPretty.length > 0)
fputs(", ", stdout);
}
2021-03-19 20:57:07 +01:00
2021-03-22 20:02:32 +01:00
ffStrbufPutTo(&gtkPretty, 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
{
2021-04-15 18:59:26 +02:00
ffPrintFormatString(instance, FF_THEME_MODULE_NAME, 0, &instance->config.themeKey, &instance->config.themeFormat, NULL, FF_THEME_NUM_FORMAT_ARGS, (FFformatarg[]){
2021-04-16 20:22:38 +02:00
{FF_FORMAT_ARG_TYPE_STRBUF, &instance->state.plasma.widgetStyle},
{FF_FORMAT_ARG_TYPE_STRBUF, &instance->state.plasma.colorScheme},
2021-04-15 18:59:26 +02:00
{FF_FORMAT_ARG_TYPE_STRBUF, &plasmaColorPretty},
2021-04-16 20:22:38 +02:00
{FF_FORMAT_ARG_TYPE_STRBUF, &instance->state.gtk2.theme},
{FF_FORMAT_ARG_TYPE_STRBUF, &instance->state.gtk3.theme},
{FF_FORMAT_ARG_TYPE_STRBUF, &instance->state.gtk4.theme},
2021-04-15 18:59:26 +02:00
{FF_FORMAT_ARG_TYPE_STRBUF, &gtkPretty}
});
2021-03-19 20:57:07 +01:00
}
2021-04-09 19:21:56 +02:00
ffStrbufDestroy(&plasmaColorPretty);
ffStrbufDestroy(&gtkPretty);
2021-03-27 18:14:19 +01:00
}