mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:14:37 +02:00
Small improvements to code quality
This commit is contained in:
+1
-1
@@ -131,7 +131,7 @@
|
||||
# Should be a valid path to an existing file.
|
||||
# Note that you might need to run fastfetch with --recache once for it to take affect.
|
||||
# Default is /etc/os-release.
|
||||
--os-file /etc/os-release
|
||||
#--os-file /etc/os-release
|
||||
|
||||
# Key options:
|
||||
# Sets the displayed key of a module
|
||||
|
||||
@@ -27,7 +27,7 @@ static bool detectFromConfigFile(const FFstrbuf* filename, FFPlasmaResult* resul
|
||||
if(line[0] == '[')
|
||||
{
|
||||
char categoryName[32];
|
||||
sscanf(line, "[%32[^]]", categoryName);
|
||||
sscanf(line, "[%31[^]]", categoryName);
|
||||
|
||||
if(strcasecmp(categoryName, "General") == 0)
|
||||
category = PLASMA_CATEGORY_GENERAL;
|
||||
|
||||
+11
-14
@@ -927,23 +927,20 @@ static void parseDefaultConfigFile(FFinstance* instance, FFdata* data)
|
||||
|
||||
ffStrbufAppendS(filename, "config.conf");
|
||||
|
||||
if(access(filename->chars, F_OK) != 0)
|
||||
FILE* file = fopen(filename->chars, "r");
|
||||
if(file != NULL)
|
||||
{
|
||||
FILE* file = fopen(filename->chars, "w");
|
||||
if(file != NULL)
|
||||
{
|
||||
fputs(FASTFETCH_DATATEXT_CONFIG, file);
|
||||
fclose(file);
|
||||
}
|
||||
parseConfigFile(instance, data, file);
|
||||
fclose(file);
|
||||
ffStrbufSubstrBefore(filename, filenameLength);
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
||||
file = fopen(filename->chars, "w");
|
||||
if(file != NULL)
|
||||
{
|
||||
FILE* file = fopen(filename->chars, "r");
|
||||
if(file != NULL)
|
||||
{
|
||||
parseConfigFile(instance, data, file);
|
||||
fclose(file);
|
||||
}
|
||||
fputs(FASTFETCH_DATATEXT_CONFIG, file);
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
ffStrbufSubstrBefore(filename, filenameLength);
|
||||
|
||||
@@ -87,7 +87,6 @@ static void printBattery(FFinstance* instance, const BatteryResult* result, uint
|
||||
{
|
||||
if(instance->config.batteryFormat.length == 0)
|
||||
{
|
||||
|
||||
ffPrintLogoAndKey(instance, FF_BATTERY_MODULE_NAME, index, &instance->config.batteryKey);
|
||||
|
||||
bool showStatus =
|
||||
|
||||
+2
-2
@@ -197,9 +197,9 @@ static void printGPUResult(FFinstance* instance, uint8_t index, FFcache* cache,
|
||||
ffStrbufSubstrAfterFirstC(&namePretty, '[');
|
||||
|
||||
FFstrbuf gpu;
|
||||
ffStrbufInitA(&gpu, result->vendor.length + namePretty.length);
|
||||
ffStrbufInitA(&gpu, result->vendor.length + 1 + namePretty.length);
|
||||
|
||||
if(*vendorPretty != '\0')
|
||||
if(ffStrSet(vendorPretty))
|
||||
{
|
||||
ffStrbufAppendS(&gpu, vendorPretty);
|
||||
ffStrbufAppendC(&gpu, ' ');
|
||||
|
||||
+8
-18
@@ -22,26 +22,16 @@ void ffPrintWM(FFinstance* instance)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, FF_WM_MODULE_NAME, 0, &instance->config.wmKey);
|
||||
|
||||
if(result->wmPrettyName.length == 0 && result->wmProcessName.length == 0)
|
||||
{
|
||||
ffStrbufPutTo(&result->wmProtocolName, stdout);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(result->wmPrettyName.length > 0)
|
||||
ffStrbufWriteTo(&result->wmPrettyName, stdout);
|
||||
else
|
||||
ffStrbufWriteTo(&result->wmProcessName, stdout);
|
||||
ffStrbufWriteTo(&result->wmPrettyName, stdout);
|
||||
|
||||
if(result->wmProtocolName.length > 0)
|
||||
{
|
||||
fputs(" (", stdout);
|
||||
ffStrbufWriteTo(&result->wmProtocolName, stdout);
|
||||
putchar(')');
|
||||
}
|
||||
|
||||
putchar('\n');
|
||||
if(result->wmProtocolName.length > 0)
|
||||
{
|
||||
fputs(" (", stdout);
|
||||
ffStrbufWriteTo(&result->wmProtocolName, stdout);
|
||||
putchar(')');
|
||||
}
|
||||
|
||||
putchar('\n');
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
+1
-1
@@ -190,7 +190,7 @@ void ffStrbufAppendVF(FFstrbuf* strbuf, const char* format, va_list arguments)
|
||||
|
||||
va_end(copy);
|
||||
|
||||
if(written <= 0)
|
||||
if(written == 0)
|
||||
return;
|
||||
|
||||
strbuf->length += written;
|
||||
|
||||
Reference in New Issue
Block a user