mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-28 15:53:51 +01:00
Made corrections
Something like this?
This commit is contained in:
+32
-34
@@ -1,4 +1,5 @@
|
||||
#include "fastfetch.h"
|
||||
#include "util/FFstrbuf.h"
|
||||
#include <string.h>
|
||||
|
||||
#define FF_WMTHEME_MODULE_NAME "WM Theme"
|
||||
@@ -38,7 +39,6 @@ static void printOpenbox(FFinstance* instance)
|
||||
{
|
||||
FFstrbuf absolutePath, theme;
|
||||
ffStrbufInitA(&absolutePath, 64);
|
||||
ffStrbufInitA(&theme, 256);
|
||||
ffStrbufAppendS(&absolutePath, instance->state.passwd->pw_dir);
|
||||
ffStrbufAppendC(&absolutePath, '/');
|
||||
|
||||
@@ -55,45 +55,43 @@ static void printOpenbox(FFinstance* instance)
|
||||
size_t len = 0;
|
||||
|
||||
FILE* file = fopen(absolutePath.chars, "r");
|
||||
if(file != NULL)
|
||||
if(file == NULL)
|
||||
{
|
||||
while(getline(&line, &len, file) != -1)
|
||||
{
|
||||
if(strstr(line, "<theme>") != 0)
|
||||
break;
|
||||
}
|
||||
while(getline(&line, &len, file) != -1)
|
||||
{
|
||||
if(strstr(line, "<name>") != 0)
|
||||
{
|
||||
ffStrbufAppendS(&theme, line);
|
||||
ffStrbufRemoveStrings(&theme, 2, "<name>", "</name>");
|
||||
ffStrbufTrimRight(&theme, '\n');
|
||||
ffStrbufTrim(&theme, ' ');
|
||||
break;
|
||||
}
|
||||
else if(strstr(line, "</theme>") != 0) // sanity check
|
||||
break;
|
||||
}
|
||||
if(line != NULL)
|
||||
free(line);
|
||||
|
||||
fclose(file);
|
||||
}
|
||||
else
|
||||
ffPrintError(instance, FF_WMTHEME_MODULE_NAME, 0, &instance->config.wmThemeKey, &instance->config.wmThemeFormat, FF_WMTHEME_NUM_FORMAT_ARGS, "Couldn't open \"%s\"", absolutePath.chars);
|
||||
|
||||
if(theme.length == 0)
|
||||
{
|
||||
ffPrintError(instance, FF_WMTHEME_MODULE_NAME, 0, &instance->config.wmThemeKey, &instance->config.wmThemeFormat, FF_WMTHEME_NUM_FORMAT_ARGS, "Couldn't find theme name in \"%s\"", absolutePath.chars);
|
||||
|
||||
ffStrbufDestroy(&theme);
|
||||
ffStrbufDestroy(&absolutePath);
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
while(getline(&line, &len, file) != -1)
|
||||
{
|
||||
if(strstr(line, "<theme>") != 0)
|
||||
break;
|
||||
}
|
||||
while(getline(&line, &len, file) != -1)
|
||||
{
|
||||
if(strstr(line, "<name>") != 0)
|
||||
{
|
||||
ffStrbufInitA(&theme, 256);
|
||||
ffStrbufAppendS(&theme, line);
|
||||
ffStrbufRemoveStrings(&theme, 2, "<name>", "</name>");
|
||||
ffStrbufTrimRight(&theme, '\n');
|
||||
ffStrbufTrim(&theme, ' ');
|
||||
break;
|
||||
}
|
||||
else if(strstr(line, "</theme>") != 0) // sanity check
|
||||
break;
|
||||
}
|
||||
if(line != NULL)
|
||||
free(line);
|
||||
|
||||
printWMTheme(instance, theme.chars);
|
||||
fclose(file);
|
||||
|
||||
|
||||
if(theme.length == 0)
|
||||
ffPrintError(instance, FF_WMTHEME_MODULE_NAME, 0, &instance->config.wmThemeKey, &instance->config.wmThemeFormat, FF_WMTHEME_NUM_FORMAT_ARGS, "Couldn't find theme name in \"%s\"", absolutePath.chars);
|
||||
else
|
||||
printWMTheme(instance, theme.chars);
|
||||
|
||||
ffStrbufDestroy(&theme);
|
||||
ffStrbufDestroy(&absolutePath);
|
||||
|
||||
Reference in New Issue
Block a user