Files
fastfetch/src/modules/theme.c
T

89 lines
2.7 KiB
C
Raw Normal View History

2021-02-18 22:25:36 +01:00
#include "fastfetch.h"
2021-02-27 18:30:05 +01:00
void ffPrintTheme(FFinstance* instance)
2021-02-18 22:25:36 +01:00
{
2021-04-09 19:21:56 +02:00
FFstrbuf* plasmaTheme;
FFstrbuf* plasmaColor;
ffCalculatePlasma(instance, &plasmaTheme, &plasmaColor, NULL, NULL);
2021-03-27 18:14:19 +01:00
2021-04-05 19:25:34 +02:00
FFstrbuf* gtk2;
ffCalculateGTK2(instance, &gtk2, NULL, NULL);
FFstrbuf* gtk3;
ffCalculateGTK3(instance, &gtk3, NULL, NULL);
FFstrbuf* gtk4;
ffCalculateGTK4(instance, &gtk4, NULL, NULL);
2021-04-09 19:21:56 +02:00
if(plasmaTheme->length == 0 && plasmaColor->length == 0 && gtk2->length == 0 && gtk3->length == 0 && gtk4->length == 0)
2021-04-05 19:25:34 +02:00
{
ffPrintError(instance, &instance->config.themeKey, "Theme", "No themes found");
return;
}
2021-03-19 20:57:07 +01:00
2021-04-09 19:21:56 +02:00
FF_STRBUF_CREATE(plasmaColorPretty);
if(ffStrbufStartsWithIgnCase(plasmaColor, plasmaTheme))
ffStrbufAppendNS(&plasmaColorPretty, plasmaColor->length - plasmaTheme->length, &plasmaColor->chars[plasmaTheme->length]);
else
ffStrbufAppend(&plasmaColorPretty, plasmaColor);
ffStrbufTrim(&plasmaColorPretty, ' ');
FF_STRBUF_CREATE(gtkPretty);
2021-04-09 14:07:05 +02:00
ffGetGtkPretty(&gtkPretty, gtk2, gtk3, gtk4);
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-03 11:39:59 +02:00
ffPrintLogoAndKey(instance, &instance->config.themeKey, "Theme");
2021-04-09 19:21:56 +02:00
if(plasmaTheme->length > 0)
{
ffStrbufWriteTo(plasmaTheme, stdout);
if(plasmaColor->length > 0)
{
fputs(" (", stdout);
if(plasmaColorPretty.length > 0)
ffStrbufWriteTo(&plasmaColorPretty, stdout);
else
ffStrbufWriteTo(plasmaColor, stdout);
putchar(')');
}
}
else if(plasmaColor->length > 0)
{
if(plasmaColorPretty.length > 0)
ffStrbufWriteTo(&plasmaColorPretty, stdout);
else
ffStrbufWriteTo(plasmaColor, stdout);
}
if(plasmaTheme->length > 0 || plasmaColor->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-09 19:21:56 +02:00
ffPrintFormatString(instance, &instance->config.themeKey, "Theme", &instance->config.themeFormat, 7,
(FFformatarg){FF_FORMAT_ARG_TYPE_STRBUF, plasmaTheme},
(FFformatarg){FF_FORMAT_ARG_TYPE_STRBUF, plasmaColor},
(FFformatarg){FF_FORMAT_ARG_TYPE_STRBUF, &plasmaColorPretty},
(FFformatarg){FF_FORMAT_ARG_TYPE_STRBUF, gtk2},
(FFformatarg){FF_FORMAT_ARG_TYPE_STRBUF, gtk3},
(FFformatarg){FF_FORMAT_ARG_TYPE_STRBUF, gtk4},
2021-03-19 20:57:07 +01:00
(FFformatarg){FF_FORMAT_ARG_TYPE_STRBUF, &gtkPretty}
);
}
2021-04-09 19:21:56 +02:00
ffStrbufDestroy(&plasmaColorPretty);
ffStrbufDestroy(&gtkPretty);
2021-03-27 18:14:19 +01:00
}