mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
+1
-1
@@ -156,7 +156,7 @@ add_library(libfastfetch OBJECT
|
||||
src/logo/image/im7.c
|
||||
src/logo/image/im6.c
|
||||
src/detection/os.c
|
||||
src/detection/plasma.c
|
||||
src/detection/qt.c
|
||||
src/detection/gtk.c
|
||||
src/detection/terminalShell.c
|
||||
src/detection/vulkan.c
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
static inline void* detectPlasmaThreadMain(void* instance)
|
||||
{
|
||||
ffDetectPlasma((FFinstance*)instance);
|
||||
ffDetectQt((FFinstance*)instance);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,15 @@
|
||||
#include <string.h>
|
||||
#include <pthread.h>
|
||||
|
||||
static inline bool allValuesSet(const FFQtResult* result)
|
||||
{
|
||||
return
|
||||
result->widgetStyle.length > 0 &&
|
||||
result->colorScheme.length > 0 &&
|
||||
result->icons.length > 0 &&
|
||||
result->font.length > 0;
|
||||
}
|
||||
|
||||
typedef enum PlasmaCategory
|
||||
{
|
||||
PLASMA_CATEGORY_GENERAL,
|
||||
@@ -12,7 +21,7 @@ typedef enum PlasmaCategory
|
||||
PLASMA_CATEGORY_OTHER
|
||||
} PlasmaCategory;
|
||||
|
||||
static bool detectFromConfigFile(const char* filename, FFPlasmaResult* result)
|
||||
static bool detectPlasmaFromFile(const char* filename, FFQtResult* result)
|
||||
{
|
||||
FILE* kdeglobals = fopen(filename, "r");
|
||||
if(kdeglobals == NULL)
|
||||
@@ -68,10 +77,62 @@ static bool detectFromConfigFile(const char* filename, FFPlasmaResult* result)
|
||||
return true;
|
||||
}
|
||||
|
||||
const FFPlasmaResult* ffDetectPlasma(FFinstance* instance)
|
||||
static void detectPlasma(const FFinstance* instance, FFQtResult* result)
|
||||
{
|
||||
bool foundAFile = false;
|
||||
|
||||
//We need to do this because we use multiple threads on configDirs
|
||||
FFstrbuf baseDir;
|
||||
ffStrbufInitA(&baseDir, 64);
|
||||
|
||||
for(uint32_t i = 0; i < instance->state.configDirs.length; i++)
|
||||
{
|
||||
ffStrbufSet(&baseDir, ffListGet(&instance->state.configDirs, i));
|
||||
ffStrbufAppendS(&baseDir, "kdeglobals");
|
||||
|
||||
if(detectPlasmaFromFile(baseDir.chars, result))
|
||||
foundAFile = true;
|
||||
|
||||
if(allValuesSet(result))
|
||||
{
|
||||
ffStrbufDestroy(&baseDir);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ffStrbufDestroy(&baseDir);
|
||||
if(!foundAFile)
|
||||
return;
|
||||
|
||||
//In Plasma the default value is never set in the config file, but the whole key-value is discarded.
|
||||
///We must set these values by our self if the file exists (it always does here)
|
||||
if(result->widgetStyle.length == 0)
|
||||
ffStrbufAppendS(&result->widgetStyle, "Breeze");
|
||||
|
||||
if(result->colorScheme.length == 0)
|
||||
ffStrbufAppendS(&result->colorScheme, "BreezeLight");
|
||||
|
||||
if(result->icons.length == 0)
|
||||
ffStrbufAppendS(&result->icons, "Breeze");
|
||||
|
||||
if(result->font.length == 0)
|
||||
ffStrbufAppendS(&result->font, "Noto Sans, 10");
|
||||
}
|
||||
|
||||
static void detectLXQt(const FFinstance* instance, FFQtResult* result)
|
||||
{
|
||||
ffParsePropFileConfigValues(instance, "lxqt/lxqt.conf", 3, (FFpropquery[]) {
|
||||
{"style = ", &result->widgetStyle},
|
||||
{"icon_theme = ", &result->icons},
|
||||
{"font = ", &result->font}
|
||||
});
|
||||
}
|
||||
|
||||
const FFQtResult* ffDetectQt(FFinstance* instance)
|
||||
{
|
||||
static FFQtResult result;
|
||||
|
||||
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
static FFPlasmaResult result;
|
||||
static bool init = false;
|
||||
pthread_mutex_lock(&mutex);
|
||||
if(init)
|
||||
@@ -87,55 +148,11 @@ const FFPlasmaResult* ffDetectPlasma(FFinstance* instance)
|
||||
ffStrbufInit(&result.font);
|
||||
|
||||
const FFDisplayServerResult* wmde = ffConnectDisplayServer(instance);
|
||||
if(ffStrbufIgnCaseCompS(&wmde->deProcessName, "plasmashell") != 0)
|
||||
{
|
||||
pthread_mutex_unlock(&mutex);
|
||||
return &result;
|
||||
}
|
||||
|
||||
bool foundAFile = false;
|
||||
|
||||
//We need to do this because we use multiple threads on configDirs
|
||||
FFstrbuf baseDir;
|
||||
ffStrbufInitA(&baseDir, 64);
|
||||
|
||||
for(uint32_t i = 0; i < instance->state.configDirs.length; i++)
|
||||
{
|
||||
ffStrbufSet(&baseDir, ffListGet(&instance->state.configDirs, i));
|
||||
ffStrbufAppendS(&baseDir, "kdeglobals");
|
||||
|
||||
if(detectFromConfigFile(baseDir.chars, &result))
|
||||
foundAFile = true;
|
||||
|
||||
if(
|
||||
result.widgetStyle.length > 0 &&
|
||||
result.colorScheme.length > 0 &&
|
||||
result.icons.length > 0 &&
|
||||
result.font.length > 0
|
||||
) break;
|
||||
}
|
||||
|
||||
ffStrbufDestroy(&baseDir);
|
||||
|
||||
if(!foundAFile)
|
||||
{
|
||||
pthread_mutex_unlock(&mutex);
|
||||
return &result;
|
||||
}
|
||||
|
||||
//In Plasma the default value is never set in the config file, but the whole key-value is discarded.
|
||||
///We must set these values by our self if the file exists (it always does here)
|
||||
if(result.widgetStyle.length == 0)
|
||||
ffStrbufAppendS(&result.widgetStyle, "Breeze");
|
||||
|
||||
if(result.colorScheme.length == 0)
|
||||
ffStrbufAppendS(&result.colorScheme, "BreezeLight");
|
||||
|
||||
if(result.icons.length == 0)
|
||||
ffStrbufAppendS(&result.icons, "Breeze");
|
||||
|
||||
if(result.font.length == 0)
|
||||
ffStrbufAppendS(&result.font, "Noto Sans, 10");
|
||||
if(ffStrbufIgnCaseCompS(&wmde->dePrettyName, "KDE Plasma") == 0)
|
||||
detectPlasma(instance, &result);
|
||||
else if(ffStrbufIgnCaseCompS(&wmde->dePrettyName, "LXQt") == 0)
|
||||
detectLXQt(instance, &result);
|
||||
|
||||
pthread_mutex_unlock(&mutex);
|
||||
return &result;
|
||||
+3
-3
@@ -202,13 +202,13 @@ typedef struct FFOSResult
|
||||
FFstrbuf architecture;
|
||||
} FFOSResult;
|
||||
|
||||
typedef struct FFPlasmaResult
|
||||
typedef struct FFQtResult
|
||||
{
|
||||
FFstrbuf widgetStyle;
|
||||
FFstrbuf colorScheme;
|
||||
FFstrbuf icons;
|
||||
FFstrbuf font;
|
||||
} FFPlasmaResult;
|
||||
} FFQtResult;
|
||||
|
||||
typedef struct FFGTKResult
|
||||
{
|
||||
@@ -522,7 +522,7 @@ void ffLogoBuiltinListAutocompletion();
|
||||
const FFOSResult* ffDetectOS(const FFinstance* instance);
|
||||
|
||||
//detection/plasma.c
|
||||
const FFPlasmaResult* ffDetectPlasma(FFinstance* instance);
|
||||
const FFQtResult* ffDetectQt(FFinstance* instance);
|
||||
|
||||
//detection/gtk.c
|
||||
const FFGTKResult* ffDetectGTK2(FFinstance* instance);
|
||||
|
||||
+2
-2
@@ -18,7 +18,7 @@ void ffPrintFont(FFinstance* instance)
|
||||
return;
|
||||
}
|
||||
|
||||
const FFstrbuf* plasmaRaw = &ffDetectPlasma(instance)->font;
|
||||
const FFstrbuf* plasmaRaw = &ffDetectQt(instance)->font;
|
||||
const FFstrbuf* gtk2Raw = &ffDetectGTK2(instance)->font;
|
||||
const FFstrbuf* gtk3Raw = &ffDetectGTK3(instance)->font;
|
||||
const FFstrbuf* gtk4Raw = &ffDetectGTK4(instance)->font;
|
||||
@@ -51,7 +51,7 @@ void ffPrintFont(FFinstance* instance)
|
||||
if(plasma.pretty.length > 0)
|
||||
{
|
||||
ffStrbufWriteTo(&plasma.pretty, stdout);
|
||||
fputs(" [Plasma]", stdout);
|
||||
fputs(" [QT]", stdout);
|
||||
|
||||
if(gtk.length > 0)
|
||||
fputs(", ", stdout);
|
||||
|
||||
+2
-2
@@ -18,7 +18,7 @@ void ffPrintIcons(FFinstance* instance)
|
||||
return;
|
||||
}
|
||||
|
||||
const FFstrbuf* plasma = &ffDetectPlasma(instance)->icons;
|
||||
const FFstrbuf* plasma = &ffDetectQt(instance)->icons;
|
||||
const FFstrbuf* gtk2 = &ffDetectGTK2(instance)->icons;
|
||||
const FFstrbuf* gtk3 = &ffDetectGTK3(instance)->icons;
|
||||
const FFstrbuf* gtk4 = &ffDetectGTK4(instance)->icons;
|
||||
@@ -39,7 +39,7 @@ void ffPrintIcons(FFinstance* instance)
|
||||
if(plasma->length > 0)
|
||||
{
|
||||
ffStrbufWriteTo(plasma, stdout);
|
||||
fputs(" [Plasma]", stdout);
|
||||
fputs(" [QT]", stdout);
|
||||
|
||||
if(gtkPretty.length > 0)
|
||||
fputs(", ", stdout);
|
||||
|
||||
+2
-2
@@ -18,7 +18,7 @@ void ffPrintTheme(FFinstance* instance)
|
||||
return;
|
||||
}
|
||||
|
||||
const FFPlasmaResult* plasma = ffDetectPlasma(instance);
|
||||
const FFQtResult* plasma = ffDetectQt(instance);
|
||||
const FFstrbuf* gtk2 = &ffDetectGTK2(instance)->theme;
|
||||
const FFstrbuf* gtk3 = &ffDetectGTK3(instance)->theme;
|
||||
const FFstrbuf* gtk4 = &ffDetectGTK4(instance)->theme;
|
||||
@@ -70,7 +70,7 @@ void ffPrintTheme(FFinstance* instance)
|
||||
|
||||
if(plasma->widgetStyle.length > 0 || plasma->colorScheme.length > 0)
|
||||
{
|
||||
fputs(" [Plasma]", stdout);
|
||||
fputs(" [QT]", stdout);
|
||||
|
||||
if(gtkPretty.length > 0)
|
||||
fputs(", ", stdout);
|
||||
|
||||
Reference in New Issue
Block a user