mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
default KWin theme
This commit is contained in:
+8
-4
@@ -325,7 +325,7 @@ void ffCacheClose(FFcache* cache)
|
||||
fclose(cache->split);
|
||||
}
|
||||
|
||||
void ffParsePropFile(const char* fileName, const char* regex, char* buffer)
|
||||
bool ffParsePropFile(const char* fileName, const char* regex, char* buffer)
|
||||
{
|
||||
buffer[0] = '\0'; //If an error occures, this is the indicator
|
||||
|
||||
@@ -334,7 +334,7 @@ void ffParsePropFile(const char* fileName, const char* regex, char* buffer)
|
||||
|
||||
FILE* file = fopen(fileName, "r");
|
||||
if(file == NULL)
|
||||
return; // handle errors in higher functions
|
||||
return false; // handle errors in higher functions
|
||||
|
||||
while (getline(&line, &len, file) != -1)
|
||||
{
|
||||
@@ -345,9 +345,11 @@ void ffParsePropFile(const char* fileName, const char* regex, char* buffer)
|
||||
fclose(file);
|
||||
if(line != NULL)
|
||||
free(line);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ffParsePropFileHome(FFinstance* instance, const char* relativeFile, const char* regex, char* buffer)
|
||||
bool ffParsePropFileHome(FFinstance* instance, const char* relativeFile, const char* regex, char* buffer)
|
||||
{
|
||||
FFstrbuf absolutePath;
|
||||
ffStrbufInitA(&absolutePath, 64);
|
||||
@@ -355,9 +357,11 @@ void ffParsePropFileHome(FFinstance* instance, const char* relativeFile, const c
|
||||
ffStrbufAppendC(&absolutePath, '/');
|
||||
ffStrbufAppendS(&absolutePath, relativeFile);
|
||||
|
||||
ffParsePropFile(absolutePath.chars, regex, buffer);
|
||||
bool result = ffParsePropFile(absolutePath.chars, regex, buffer);
|
||||
|
||||
ffStrbufDestroy(&absolutePath);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool ffWriteFDContent(int fd, const FFstrbuf* content)
|
||||
|
||||
+3
-2
@@ -239,8 +239,9 @@ void ffGetFileContent(const char* fileName, FFstrbuf* buffer);
|
||||
bool ffWriteFDContent(int fd, const FFstrbuf* content);
|
||||
void ffWriteFileContent(const char* fileName, const FFstrbuf* buffer);
|
||||
|
||||
void ffParsePropFile(const char* file, const char* regex, char* buffer);
|
||||
void ffParsePropFileHome(FFinstance* instance, const char* relativeFile, const char* regex, char* buffer);
|
||||
// They return true if the file was found, independently if regex was found
|
||||
bool ffParsePropFile(const char* file, const char* regex, char* buffer);
|
||||
bool ffParsePropFileHome(FFinstance* instance, const char* relativeFile, const char* regex, char* buffer);
|
||||
|
||||
//common/processing.c
|
||||
void ffProcessAppendStdOut(FFstrbuf* buffer, char* const argv[]);
|
||||
|
||||
@@ -22,13 +22,17 @@ static void printWMTheme(FFinstance* instance, const char* theme)
|
||||
static void printKWin(FFinstance* instance)
|
||||
{
|
||||
char theme[256];
|
||||
theme[0] = '\0';
|
||||
ffParsePropFileHome(instance, ".config/kwinrc", "theme=%s", theme);
|
||||
bool fileFound = ffParsePropFileHome(instance, ".config/kwinrc", "theme=%s", theme);
|
||||
|
||||
if(theme[0] == '\0')
|
||||
if(*theme == '\0')
|
||||
{
|
||||
ffPrintError(instance, FF_WMTHEME_MODULE_NAME, 0, &instance->config.wmThemeKey, &instance->config.wmThemeFormat, FF_WMTHEME_NUM_FORMAT_ARGS, "Couldn't find \"theme=\" in \".config/kwinrc\"");
|
||||
return;
|
||||
if(!fileFound)
|
||||
{
|
||||
ffPrintError(instance, FF_WMTHEME_MODULE_NAME, 0, &instance->config.wmThemeKey, &instance->config.wmThemeFormat, FF_WMTHEME_NUM_FORMAT_ARGS, "Couldn't find \"theme=\" in \".config/kwinrc\"");
|
||||
return;
|
||||
}
|
||||
|
||||
strcpy(theme, "Breeze");
|
||||
}
|
||||
|
||||
printWMTheme(instance, theme);
|
||||
|
||||
Reference in New Issue
Block a user