mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-11-08 06:00:08 +01:00
faster plasma detection
This commit is contained in:
@@ -165,7 +165,7 @@ static void calculateGTKFromConfigDir(const char* configDir, const char* version
|
||||
FFstrbuf file4;
|
||||
ffStrbufInitA(&file4, 64);
|
||||
ffStrbufAppendS(&file4, configDir);
|
||||
ffStrbufAppendS(&file4, "gtkrc-");
|
||||
ffStrbufAppendS(&file4, ".gtkrc-");
|
||||
ffStrbufAppendS(&file4, version);
|
||||
ffStrbufAppendS(&file4, ".0");
|
||||
parseGTKConfigFile(&file4, themeNamePtr, iconsNamePtr, fontNamePtr);
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
#include "fastfetch.h"
|
||||
|
||||
void ffCalculatePlasma(FFinstance* instance, FFstrbuf** themeNamePtr, FFstrbuf** iconsNamePtr, FFstrbuf** fontNamePtr)
|
||||
{
|
||||
static FFstrbuf themeName;
|
||||
static FFstrbuf iconsName;
|
||||
static FFstrbuf fontName;
|
||||
|
||||
if(themeNamePtr != NULL)
|
||||
*themeNamePtr = &themeName;
|
||||
|
||||
if(iconsNamePtr != NULL)
|
||||
*iconsNamePtr = &iconsName;
|
||||
|
||||
if(fontNamePtr != NULL)
|
||||
*fontNamePtr = &fontName;
|
||||
|
||||
static bool init = false;
|
||||
if(init)
|
||||
return;
|
||||
init = true;
|
||||
|
||||
ffStrbufInit(&themeName);
|
||||
ffStrbufInit(&iconsName);
|
||||
ffStrbufInit(&fontName);
|
||||
|
||||
FF_STRBUF_CREATE(kdeglobalsFile);
|
||||
ffStrbufAppendS(&kdeglobalsFile, instance->state.passwd->pw_dir);
|
||||
ffStrbufAppendS(&kdeglobalsFile, "/.config/kdeglobals");
|
||||
|
||||
FILE* kdeglobals = fopen(kdeglobalsFile.chars, "r");
|
||||
if(kdeglobals == NULL)
|
||||
{
|
||||
ffStrbufDestroy(&kdeglobalsFile);
|
||||
return;
|
||||
}
|
||||
|
||||
char* line = NULL;
|
||||
size_t len = 0;
|
||||
|
||||
while(getline(&line, &len, kdeglobals) != -1)
|
||||
{
|
||||
sscanf(line, "widgetStyle=%[^\n]", themeName.chars);
|
||||
sscanf(line, "widgetStyle=\"%[^\"]+", themeName.chars);
|
||||
|
||||
sscanf(line, "Theme=%[^\n]", iconsName.chars);
|
||||
sscanf(line, "Theme=\"%[^\"]+", iconsName.chars);
|
||||
|
||||
sscanf(line, "font=%[^\n]", fontName.chars);
|
||||
sscanf(line, "font=\"%[^\"]+", fontName.chars);
|
||||
}
|
||||
|
||||
ffStrbufRecalculateLength(&themeName);
|
||||
ffStrbufRecalculateLength(&iconsName);
|
||||
ffStrbufRecalculateLength(&fontName);
|
||||
|
||||
if(line != NULL)
|
||||
free(line);
|
||||
|
||||
fclose(kdeglobals);
|
||||
ffStrbufDestroy(&kdeglobalsFile);
|
||||
|
||||
//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.
|
||||
if(fontName.length == 0)
|
||||
ffStrbufAppendS(&fontName, "Noto Sans, 10");
|
||||
}
|
||||
Reference in New Issue
Block a user