mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-30 00:37:23 +01:00
faster plasma detection
This commit is contained in:
+9
-30
@@ -4,20 +4,8 @@
|
||||
|
||||
void ffPrintFont(FFinstance* instance)
|
||||
{
|
||||
FF_STRBUF_CREATE(plasmaFile);
|
||||
ffStrbufAppendS(&plasmaFile, instance->state.passwd->pw_dir);
|
||||
ffStrbufAppendS(&plasmaFile, "/.config/kdeglobals");
|
||||
|
||||
//When using Noto Sans 10, the default font in KDE Plasma, the font entry is deleted from the config file instead of set.
|
||||
//So the pure existence of the file sets this font value if not set other in the file itself.
|
||||
bool plasmaFileExists = access(plasmaFile.chars, F_OK) == 0;
|
||||
|
||||
char plasma[256];
|
||||
plasma[0] = '\0';
|
||||
if(plasmaFileExists)
|
||||
ffParsePropFile(plasmaFile.chars, "font=%[^\n]", plasma);
|
||||
|
||||
ffStrbufDestroy(&plasmaFile);
|
||||
FFstrbuf* plasma;
|
||||
ffCalculatePlasma(instance, NULL, NULL, &plasma);
|
||||
|
||||
FFstrbuf* gtk2;
|
||||
ffCalculateGTK2(instance, NULL, NULL, >k2);
|
||||
@@ -28,28 +16,17 @@ void ffPrintFont(FFinstance* instance)
|
||||
FFstrbuf* gtk4;
|
||||
ffCalculateGTK4(instance, NULL, NULL, >k4);
|
||||
|
||||
if(plasma[0] == '\0' && !plasmaFileExists && gtk2->length == 0 && gtk3->length == 0 && gtk4->length == 0)
|
||||
if(plasma->length == 0 && gtk2->length == 0 && gtk3->length == 0 && gtk4->length == 0)
|
||||
{
|
||||
ffPrintError(instance, &instance->config.fontKey, "Font", "No fonts found");
|
||||
return;
|
||||
}
|
||||
|
||||
FF_STRBUF_CREATE(plasmaName);
|
||||
FF_STRBUF_CREATE(plasmaPretty);
|
||||
double plasmaSize;
|
||||
|
||||
if(plasma[0] == '\0' && plasmaFileExists)
|
||||
{
|
||||
strcpy(plasma, "Noto Sans, 10");
|
||||
ffStrbufSetS(&plasmaName, "Noto Sans");
|
||||
plasmaSize = 10;
|
||||
ffStrbufSetS(&plasmaPretty, "Noto Sans (10pt)");
|
||||
}
|
||||
else
|
||||
{
|
||||
ffParseFont(plasma, &plasmaName, &plasmaSize);
|
||||
ffFontPretty(&plasmaPretty, &plasmaName, plasmaSize);
|
||||
}
|
||||
ffParseFont(plasma->chars, &plasmaName, &plasmaSize);
|
||||
FF_STRBUF_CREATE(plasmaPretty);
|
||||
ffFontPretty(&plasmaPretty, &plasmaName, plasmaSize);
|
||||
|
||||
FF_STRBUF_CREATE(gtk2Name);
|
||||
double gtk2Size;
|
||||
@@ -76,7 +53,7 @@ void ffPrintFont(FFinstance* instance)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, &instance->config.fontKey, "Font");
|
||||
|
||||
if(plasma[0] != '\0')
|
||||
if(plasma->length > 0)
|
||||
{
|
||||
ffStrbufWriteTo(&plasmaPretty, stdout);
|
||||
fputs(" [Plasma]", stdout);
|
||||
@@ -120,4 +97,6 @@ void ffPrintFont(FFinstance* instance)
|
||||
|
||||
ffStrbufDestroy(>k3Name);
|
||||
ffStrbufDestroy(>k3Pretty);
|
||||
|
||||
ffStrbufDestroy(>kPretty);
|
||||
}
|
||||
|
||||
+11
-7
@@ -2,8 +2,8 @@
|
||||
|
||||
void ffPrintIcons(FFinstance* instance)
|
||||
{
|
||||
char plasma[256];
|
||||
ffParsePropFileHome(instance, ".config/kdeglobals", "Theme=%[^\n]", plasma);
|
||||
FFstrbuf* plasma;
|
||||
ffCalculatePlasma(instance, NULL, &plasma, NULL);
|
||||
|
||||
FFstrbuf* gtk2;
|
||||
ffCalculateGTK2(instance, NULL, >k2, NULL);
|
||||
@@ -14,7 +14,7 @@ void ffPrintIcons(FFinstance* instance)
|
||||
FFstrbuf* gtk4;
|
||||
ffCalculateGTK4(instance, NULL, >k4, NULL);
|
||||
|
||||
if(plasma[0] == '\0' && gtk2->length == 0 && gtk3->length == 0 && gtk4->length == 0)
|
||||
if(plasma->length == 0 && gtk2->length == 0 && gtk3->length == 0 && gtk4->length == 0)
|
||||
{
|
||||
ffPrintError(instance, &instance->config.iconsKey, "Icons", "No icons found");
|
||||
return;
|
||||
@@ -27,10 +27,14 @@ void ffPrintIcons(FFinstance* instance)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, &instance->config.iconsKey, "Icons");
|
||||
|
||||
if(plasma[0] == '\0')
|
||||
printf("Breeze [Plasma], ");
|
||||
else
|
||||
printf("%s [Plasma], ", plasma);
|
||||
if(plasma->length > 0)
|
||||
{
|
||||
ffStrbufWriteTo(plasma, stdout);
|
||||
fputs(" [Plasma]", stdout);
|
||||
|
||||
if(gtkPretty.length > 0)
|
||||
fputs(", ", stdout);
|
||||
}
|
||||
|
||||
ffStrbufPutTo(>kPretty, stdout);
|
||||
}
|
||||
|
||||
+11
-5
@@ -2,8 +2,8 @@
|
||||
|
||||
void ffPrintTheme(FFinstance* instance)
|
||||
{
|
||||
char plasma[256];
|
||||
ffParsePropFileHome(instance, ".config/kdeglobals", "Name=%[^\n]", plasma);
|
||||
FFstrbuf* plasma;
|
||||
ffCalculatePlasma(instance, &plasma, NULL, NULL);
|
||||
|
||||
FFstrbuf* gtk2;
|
||||
ffCalculateGTK2(instance, >k2, NULL, NULL);
|
||||
@@ -14,7 +14,7 @@ void ffPrintTheme(FFinstance* instance)
|
||||
FFstrbuf* gtk4;
|
||||
ffCalculateGTK4(instance, >k4, NULL, NULL);
|
||||
|
||||
if(plasma[0] == '\0' && gtk2->length == 0 && gtk3->length == 0 && gtk4->length == 0)
|
||||
if(plasma->length == 0 && gtk2->length == 0 && gtk3->length == 0 && gtk4->length == 0)
|
||||
{
|
||||
ffPrintError(instance, &instance->config.themeKey, "Theme", "No themes found");
|
||||
return;
|
||||
@@ -27,8 +27,14 @@ void ffPrintTheme(FFinstance* instance)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, &instance->config.themeKey, "Theme");
|
||||
|
||||
if(plasma[0] != '\0')
|
||||
printf("%s [Plasma], ", plasma);
|
||||
if(plasma->length > 0)
|
||||
{
|
||||
ffStrbufWriteTo(plasma, stdout);
|
||||
fputs(" [Plasma]", stdout);
|
||||
|
||||
if(gtkPretty.length > 0)
|
||||
fputs(", ", stdout);
|
||||
}
|
||||
|
||||
ffStrbufPutTo(>kPretty, stdout);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user