Files
fastfetch/src/detection/theme/theme_linux.c
T

61 lines
2.1 KiB
C
Raw Normal View History

2023-06-08 14:32:15 +08:00
#include "theme.h"
#include "common/parsing.h"
#include "detection/gtk_qt/gtk_qt.h"
#include "detection/displayserver/displayserver.h"
2026-03-29 09:28:49 +08:00
const char* ffDetectTheme(FFThemeResult* result) {
const FFDisplayServerResult* wmde = ffConnectDisplayServer();
2023-06-08 14:32:15 +08:00
2026-03-29 09:28:49 +08:00
if (ffStrbufIgnCaseEqualS(&wmde->wmProtocolName, FF_WM_PROTOCOL_TTY)) {
2023-06-08 14:32:15 +08:00
return "Theme isn't supported in TTY";
2026-03-29 09:28:49 +08:00
}
2023-06-08 14:32:15 +08:00
const FFQtResult* plasma = ffDetectQt();
const FFstrbuf* gtk2 = &ffDetectGTK2()->theme;
const FFstrbuf* gtk3 = &ffDetectGTK3()->theme;
const FFstrbuf* gtk4 = &ffDetectGTK4()->theme;
2023-06-08 14:32:15 +08:00
2026-03-29 09:28:49 +08:00
if (plasma->widgetStyle.length == 0 && plasma->colorScheme.length == 0 && gtk2->length == 0 && gtk3->length == 0 && gtk4->length == 0) {
2023-06-08 14:32:15 +08:00
return "No themes found";
2026-03-29 09:28:49 +08:00
}
2023-06-08 14:32:15 +08:00
ffParseGTK(&result->theme2, gtk2, gtk3, gtk4);
FF_STRBUF_AUTO_DESTROY plasmaColorPretty = ffStrbufCreate();
2026-03-29 09:28:49 +08:00
if (ffStrbufStartsWithIgnCase(&plasma->colorScheme, &plasma->widgetStyle)) {
2023-06-08 14:32:15 +08:00
ffStrbufAppendNS(&plasmaColorPretty, plasma->colorScheme.length - plasma->widgetStyle.length, &plasma->colorScheme.chars[plasma->widgetStyle.length]);
2026-03-29 09:28:49 +08:00
} else {
2023-06-08 14:32:15 +08:00
ffStrbufAppend(&plasmaColorPretty, &plasma->colorScheme);
2026-03-29 09:28:49 +08:00
}
2023-06-08 14:32:15 +08:00
ffStrbufTrim(&plasmaColorPretty, ' ');
2026-03-29 09:28:49 +08:00
if (plasma->widgetStyle.length > 0) {
ffStrbufAppend(&result->theme1, &plasma->widgetStyle);
2023-06-08 14:32:15 +08:00
2026-03-29 09:28:49 +08:00
if (plasma->colorScheme.length > 0) {
ffStrbufAppendS(&result->theme1, " (");
2023-06-08 14:32:15 +08:00
2026-03-29 09:28:49 +08:00
if (plasmaColorPretty.length > 0) {
ffStrbufAppend(&result->theme1, &plasmaColorPretty);
2026-03-29 09:28:49 +08:00
} else {
ffStrbufAppend(&result->theme1, &plasma->colorScheme);
2026-03-29 09:28:49 +08:00
}
2023-06-08 14:32:15 +08:00
ffStrbufAppendC(&result->theme1, ')');
2023-06-08 14:32:15 +08:00
}
2026-03-29 09:28:49 +08:00
} else if (plasma->colorScheme.length > 0) {
if (plasmaColorPretty.length > 0) {
ffStrbufAppend(&result->theme1, &plasmaColorPretty);
2026-03-29 09:28:49 +08:00
} else {
ffStrbufAppend(&result->theme1, &plasma->colorScheme);
2026-03-29 09:28:49 +08:00
}
2023-06-08 14:32:15 +08:00
}
2026-03-29 09:28:49 +08:00
if (plasma->widgetStyle.length > 0 || plasma->colorScheme.length > 0) {
2024-07-01 03:38:29 -03:00
ffStrbufAppendS(&result->theme1, " [Qt]");
2026-03-29 09:28:49 +08:00
}
2023-06-08 14:32:15 +08:00
2026-07-10 18:08:04 +08:00
return nullptr;
2023-06-08 14:32:15 +08:00
}