mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-29 08:13:44 +01:00
dont print line if format evaluates to an empty string
This commit is contained in:
+50
-9
@@ -293,6 +293,9 @@ bool ffPrintCachedValue(FFinstance* instance, const char* key)
|
||||
|
||||
void ffPrintAndSaveCachedValue(FFinstance* instance, const char* key, FFstrbuf* value)
|
||||
{
|
||||
if(value->length == 0)
|
||||
return;
|
||||
|
||||
ffPrintLogoAndKey(instance, key);
|
||||
ffStrbufPutTo(value, stdout);
|
||||
|
||||
@@ -318,18 +321,12 @@ void ffPrintAndSaveCachedValue(FFinstance* instance, const char* key, FFstrbuf*
|
||||
ffStrbufDestroy(&cacheFile);
|
||||
}
|
||||
|
||||
void ffParseFormatString(FFstrbuf* buffer, FFstrbuf* formatstr, uint32_t numArgs, ...)
|
||||
void ffParseFormatStringV(FFstrbuf* buffer, FFstrbuf* formatstr, uint32_t numArgs, va_list argp)
|
||||
{
|
||||
va_list argp;
|
||||
va_start(argp, numArgs);
|
||||
|
||||
FFformatarg arguments[numArgs];
|
||||
|
||||
for(uint32_t i = 0; i < numArgs; i++)
|
||||
arguments[i] = (FFformatarg) va_arg(argp, FFformatarg);
|
||||
|
||||
va_end(argp);
|
||||
|
||||
uint32_t argCounter = 1; //First arg is 1 in fomat string
|
||||
|
||||
for(uint32_t i = 0; i < formatstr->length; ++i)
|
||||
@@ -340,6 +337,12 @@ void ffParseFormatString(FFstrbuf* buffer, FFstrbuf* formatstr, uint32_t numArgs
|
||||
continue;
|
||||
}
|
||||
|
||||
if(i == formatstr->length - 1)
|
||||
{
|
||||
ffStrbufAppendC(buffer, '{');
|
||||
continue; //This will always stop the loop
|
||||
}
|
||||
|
||||
++i;
|
||||
|
||||
if(formatstr->chars[i] == '{')
|
||||
@@ -352,6 +355,12 @@ void ffParseFormatString(FFstrbuf* buffer, FFstrbuf* formatstr, uint32_t numArgs
|
||||
|
||||
if(formatstr->chars[i] == '}')
|
||||
{
|
||||
if(argCounter > numArgs)
|
||||
{
|
||||
ffStrbufAppendS(buffer, "{}");
|
||||
continue;
|
||||
}
|
||||
|
||||
argIndex = argCounter++;
|
||||
}
|
||||
else
|
||||
@@ -359,17 +368,18 @@ void ffParseFormatString(FFstrbuf* buffer, FFstrbuf* formatstr, uint32_t numArgs
|
||||
FFstrbuf argnumstr;
|
||||
ffStrbufInit(&argnumstr);
|
||||
|
||||
while(formatstr->chars[i] != '}' && formatstr->chars[i] != '\0')
|
||||
while(formatstr->chars[i] != '}' && i < formatstr->length)
|
||||
ffStrbufAppendC(&argnumstr, formatstr->chars[i++]);
|
||||
|
||||
if(
|
||||
argnumstr.length == 0 ||
|
||||
ffStrbufGetC(&argnumstr, 0) == '-' ||
|
||||
sscanf(argnumstr.chars, "%u", &argIndex) != 1 ||
|
||||
argIndex > numArgs
|
||||
) {
|
||||
ffStrbufAppendC(buffer, '{');
|
||||
ffStrbufAppend(buffer, &argnumstr);
|
||||
if(formatstr->chars[i] != '\0')
|
||||
if(formatstr->chars[i] == '}') // We dont have a closing { when ending because whole format string is over
|
||||
ffStrbufAppendC(buffer, '}');
|
||||
ffStrbufDestroy(&argnumstr);
|
||||
continue;
|
||||
@@ -402,4 +412,35 @@ void ffParseFormatString(FFstrbuf* buffer, FFstrbuf* formatstr, uint32_t numArgs
|
||||
exit(806);
|
||||
}
|
||||
}
|
||||
|
||||
ffStrbufTrimRight(buffer, ' ');
|
||||
}
|
||||
|
||||
void ffParseFormatString(FFstrbuf* buffer, FFstrbuf* formatstr, uint32_t numArgs, ...)
|
||||
{
|
||||
va_list argp;
|
||||
va_start(argp, numArgs);
|
||||
ffParseFormatStringV(buffer, formatstr, numArgs, argp);
|
||||
va_end(argp);
|
||||
}
|
||||
|
||||
void ffPrintFormatString(FFinstance* instance, const char* key, FFstrbuf* formatstr, uint32_t numArgs, ...)
|
||||
{
|
||||
FFstrbuf buffer;
|
||||
ffStrbufInitA(&buffer, 256);
|
||||
|
||||
va_list argp;
|
||||
va_start(argp, numArgs);
|
||||
|
||||
ffParseFormatStringV(&buffer, formatstr, numArgs, argp);
|
||||
|
||||
va_end(argp);
|
||||
|
||||
if(buffer.length > 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, key);
|
||||
ffStrbufPutTo(&buffer, stdout);
|
||||
}
|
||||
|
||||
ffStrbufDestroy(&buffer);
|
||||
}
|
||||
@@ -121,6 +121,10 @@ static inline void printCommandHelpFormat()
|
||||
"If a value index is missformatted or wants a non existing value, it will be printed as is, with the curly braces around it.\n"
|
||||
"If the last placeholder isn't closed, it will be printed as is, with the open curly braces at the start.\n"
|
||||
"\n"
|
||||
"If an format string evaluates to an empty value, the whole line in the output will be discarded.\n"
|
||||
"You can therefore use --host-format \" \" to disable host output.\n"
|
||||
"Note that --host-format \"\" would evaluate as not set, and therefore use the built in host format\n"
|
||||
"\n"
|
||||
"Format string is also the way to go to set a fixed value, just use one without placeholders.\n"
|
||||
"For example when running in headless mode you could use \"--resolution-format \"Preferred\"."
|
||||
);
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
@@ -124,7 +125,9 @@ void ffFormatGtkPretty(FFstrbuf* buffer, const char* gtk2, const char* gtk3, con
|
||||
void ffPrintError(FFinstance* instance, const char* key, const char* message, ...);
|
||||
bool ffPrintCachedValue(FFinstance* instance, const char* key);
|
||||
void ffPrintAndSaveCachedValue(FFinstance* instance, const char* key, FFstrbuf* value);
|
||||
void ffParseFormatStringV(FFstrbuf* buffer, FFstrbuf* formatstr, uint32_t numArgs, va_list argp);
|
||||
void ffParseFormatString(FFstrbuf* buffer, FFstrbuf* formatstr, uint32_t numArgs, ...);
|
||||
void ffPrintFormatString(FFinstance* instance, const char* key, FFstrbuf* formatstr, uint32_t numArgs, ...);
|
||||
void ffFinish(FFinstance* instance);
|
||||
|
||||
//Logo functions
|
||||
|
||||
+14
-20
@@ -32,22 +32,21 @@ static void printBattery(FFinstance* instance, uint8_t index)
|
||||
char key[10];
|
||||
sprintf(key, "Battery %i", index);
|
||||
|
||||
if(
|
||||
manufactor.length == 0 &&
|
||||
model.length == 0 &&
|
||||
technology.length == 0 &&
|
||||
capacity.length == 0 &&
|
||||
status.length == 0 &&
|
||||
instance->config.batteryFormat.length == 0
|
||||
) {
|
||||
ffPrintError(instance, key, "No file in /sys/class/power_supply/BAT0/ could be read or all battery options are disabled");
|
||||
return;
|
||||
}
|
||||
|
||||
ffPrintLogoAndKey(instance, key);
|
||||
|
||||
if(instance->config.batteryFormat.length == 0)
|
||||
{
|
||||
if(
|
||||
manufactor.length == 0 &&
|
||||
model.length == 0 &&
|
||||
technology.length == 0 &&
|
||||
capacity.length == 0 &&
|
||||
status.length == 0
|
||||
) {
|
||||
ffPrintError(instance, key, "No file in /sys/class/power_supply/BAT0/ could be read or all battery options are disabled");
|
||||
return;
|
||||
}
|
||||
|
||||
ffPrintLogoAndKey(instance, key);
|
||||
|
||||
if(manufactor.length > 0)
|
||||
printf("%s ", manufactor.chars);
|
||||
|
||||
@@ -76,18 +75,13 @@ static void printBattery(FFinstance* instance, uint8_t index)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_STRBUF_CREATE(battery);
|
||||
|
||||
ffParseFormatString(&battery, &instance->config.batteryFormat, 5,
|
||||
ffPrintFormatString(instance, key, &instance->config.batteryFormat, 5,
|
||||
(FFformatarg){FF_FORMAT_ARG_TYPE_STRBUF, &manufactor},
|
||||
(FFformatarg){FF_FORMAT_ARG_TYPE_STRBUF, &model},
|
||||
(FFformatarg){FF_FORMAT_ARG_TYPE_STRBUF, &technology},
|
||||
(FFformatarg){FF_FORMAT_ARG_TYPE_STRBUF, &capacity},
|
||||
(FFformatarg){FF_FORMAT_ARG_TYPE_STRBUF, &status}
|
||||
);
|
||||
|
||||
ffStrbufPutTo(&battery, stdout);
|
||||
ffStrbufDestroy(&battery);
|
||||
}
|
||||
|
||||
ffStrbufDestroy(&manufactor);
|
||||
|
||||
+1
-8
@@ -69,18 +69,11 @@ void ffPrintDesktopEnvironment(FFinstance* instance)
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintLogoAndKey(instance, "DE");
|
||||
|
||||
FF_STRBUF_CREATE(de);
|
||||
|
||||
ffParseFormatString(&de, &instance->config.deFormat, 3,
|
||||
ffPrintFormatString(instance, "DE", &instance->config.deFormat, 3,
|
||||
(FFformatarg){FF_FORMAT_ARG_TYPE_STRBUF, &sessionDesktop},
|
||||
(FFformatarg){FF_FORMAT_ARG_TYPE_STRBUF, &sessionVersion},
|
||||
(FFformatarg){FF_FORMAT_ARG_TYPE_STRBUF, &sessionType}
|
||||
);
|
||||
|
||||
ffStrbufPutTo(&de, stdout);
|
||||
ffStrbufDestroy(&de);
|
||||
}
|
||||
ffStrbufDestroy(&sessionType);
|
||||
ffStrbufDestroy(&sessionVersion);
|
||||
|
||||
+4
-10
@@ -12,30 +12,24 @@ void ffPrintDisk(FFinstance* instance)
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t GB = (1024 * 1024) * 1024;
|
||||
const uint32_t GB = (1024 * 1024) * 1024;
|
||||
|
||||
uint32_t total = (fs.f_blocks * fs.f_frsize) / GB;
|
||||
uint32_t available = (fs.f_bfree * fs.f_frsize) / GB;
|
||||
uint32_t used = total - available;
|
||||
uint32_t used = total - available;
|
||||
uint8_t percentage = (used / (double) total) * 100.0;
|
||||
|
||||
ffPrintLogoAndKey(instance, "Disk (/)");
|
||||
|
||||
if(instance->config.diskFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, "Disk (/)");
|
||||
printf("%uGB / %uGB (%u%%)\n", used, total, percentage);
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_STRBUF_CREATE(disk);
|
||||
|
||||
ffParseFormatString(&disk, &instance->config.diskFormat, 3,
|
||||
ffPrintFormatString(instance, "Disk (/)", &instance->config.diskFormat, 3,
|
||||
(FFformatarg){FF_FORMAT_ARG_TYPE_UINT, &used},
|
||||
(FFformatarg){FF_FORMAT_ARG_TYPE_UINT, &total},
|
||||
(FFformatarg){FF_FORMAT_ARG_TYPE_UINT8, &percentage}
|
||||
);
|
||||
|
||||
ffStrbufPutTo(&disk, stdout);
|
||||
ffStrbufDestroy(&disk);
|
||||
}
|
||||
}
|
||||
+2
-8
@@ -41,27 +41,21 @@ void ffPrintFont(FFinstance* instance)
|
||||
FF_STRBUF_CREATE(gtkPretty);
|
||||
ffFormatGtkPretty(>kPretty, gtk2Pretty, gtk3Pretty, gtk4Pretty);
|
||||
|
||||
ffPrintLogoAndKey(instance, "Font");
|
||||
|
||||
if(instance->config.fontFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, "Font");
|
||||
printf("%s [Plasma], ", plasmaPretty);
|
||||
ffStrbufPutTo(>kPretty, stdout);
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_STRBUF_CREATE(font);
|
||||
|
||||
ffParseFormatString(&font, &instance->config.fontFormat, 5,
|
||||
ffPrintFormatString(instance, "Font", &instance->config.fontFormat, 5,
|
||||
(FFformatarg){FF_FORMAT_ARG_TYPE_STRING, plasmaPretty},
|
||||
(FFformatarg){FF_FORMAT_ARG_TYPE_STRING, gtk2Pretty},
|
||||
(FFformatarg){FF_FORMAT_ARG_TYPE_STRING, gtk3Pretty},
|
||||
(FFformatarg){FF_FORMAT_ARG_TYPE_STRING, gtk4Pretty},
|
||||
(FFformatarg){FF_FORMAT_ARG_TYPE_STRBUF, >kPretty}
|
||||
);
|
||||
|
||||
ffStrbufPutTo(&font, stdout);
|
||||
ffStrbufDestroy(&font);
|
||||
}
|
||||
|
||||
ffStrbufDestroy(>kPretty);
|
||||
|
||||
+3
-8
@@ -23,10 +23,10 @@ void ffPrintIcons(FFinstance* instance)
|
||||
FF_STRBUF_CREATE(gtkPretty);
|
||||
ffFormatGtkPretty(>kPretty, gtk2, gtk3, gtk4);
|
||||
|
||||
ffPrintLogoAndKey(instance, "Icons");
|
||||
|
||||
if(instance->config.iconsFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, "Icons");
|
||||
|
||||
if(plasma[0] == '\0')
|
||||
printf("Breeze [Plasma], ");
|
||||
else
|
||||
@@ -36,18 +36,13 @@ void ffPrintIcons(FFinstance* instance)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_STRBUF_CREATE(icons);
|
||||
|
||||
ffParseFormatString(&icons, &instance->config.iconsFormat, 5,
|
||||
ffPrintFormatString(instance, "Icons", &instance->config.iconsFormat, 5,
|
||||
(FFformatarg){FF_FORMAT_ARG_TYPE_STRING, plasma},
|
||||
(FFformatarg){FF_FORMAT_ARG_TYPE_STRING, gtk2},
|
||||
(FFformatarg){FF_FORMAT_ARG_TYPE_STRING, gtk3},
|
||||
(FFformatarg){FF_FORMAT_ARG_TYPE_STRING, gtk4},
|
||||
(FFformatarg){FF_FORMAT_ARG_TYPE_STRBUF, >kPretty}
|
||||
);
|
||||
|
||||
ffStrbufPutTo(&icons, stdout);
|
||||
ffStrbufDestroy(&icons);
|
||||
}
|
||||
|
||||
ffStrbufDestroy(>kPretty);
|
||||
|
||||
+8
-13
@@ -6,18 +6,13 @@ void ffPrintKernel(FFinstance* instance)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, "Kernel");
|
||||
puts(instance->state.utsname.release);
|
||||
return;
|
||||
}
|
||||
|
||||
FF_STRBUF_CREATE(kernel);
|
||||
|
||||
ffParseFormatString(&kernel, &instance->config.kernelFormat, 3,
|
||||
(FFformatarg){FF_FORMAT_ARG_TYPE_STRING, instance->state.utsname.sysname},
|
||||
(FFformatarg){FF_FORMAT_ARG_TYPE_STRING, instance->state.utsname.release},
|
||||
(FFformatarg){FF_FORMAT_ARG_TYPE_STRING, instance->state.utsname.version}
|
||||
);
|
||||
|
||||
ffPrintLogoAndKey(instance, "Kernel");
|
||||
ffStrbufPutTo(&kernel, stdout);
|
||||
ffStrbufDestroy(&kernel);
|
||||
else
|
||||
{
|
||||
ffPrintFormatString(instance, "Kernel", &instance->config.kernelFormat, 3,
|
||||
(FFformatarg){FF_FORMAT_ARG_TYPE_STRING, instance->state.utsname.sysname},
|
||||
(FFformatarg){FF_FORMAT_ARG_TYPE_STRING, instance->state.utsname.release},
|
||||
(FFformatarg){FF_FORMAT_ARG_TYPE_STRING, instance->state.utsname.version}
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -30,23 +30,17 @@ void ffPrintMemory(FFinstance* instance)
|
||||
uint32_t total_mem = total / 1024;
|
||||
uint8_t percentage = (uint8_t) ((used_mem / (double) total_mem) * 100);
|
||||
|
||||
ffPrintLogoAndKey(instance, "Memory");
|
||||
|
||||
if(instance->config.memoryFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, "Memory");
|
||||
printf("%uMiB / %uMiB (%u%%)\n", used_mem, total_mem, percentage);
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_STRBUF_CREATE(memory);
|
||||
|
||||
ffParseFormatString(&memory, &instance->config.memoryFormat, 3,
|
||||
ffPrintFormatString(instance, "Memory", &instance->config.memoryFormat, 3,
|
||||
(FFformatarg){FF_FORMAT_ARG_TYPE_UINT, &used_mem},
|
||||
(FFformatarg){FF_FORMAT_ARG_TYPE_UINT, &total_mem},
|
||||
(FFformatarg){FF_FORMAT_ARG_TYPE_UINT8, &percentage}
|
||||
);
|
||||
|
||||
ffStrbufPutTo(&memory, stdout);
|
||||
ffStrbufDestroy(&memory);
|
||||
}
|
||||
}
|
||||
+14
-19
@@ -30,14 +30,14 @@ void ffPrintPackages(FFinstance* instance)
|
||||
|
||||
uint32_t all = pacman + flatpak;
|
||||
|
||||
if(all == 0)
|
||||
{
|
||||
ffPrintError(instance, "Packages", "No packages from known package managers found");
|
||||
return;
|
||||
}
|
||||
|
||||
if(instance->config.packagesFormat.length == 0)
|
||||
{
|
||||
if(all == 0)
|
||||
{
|
||||
ffPrintError(instance, "Packages", "No packages from known package managers found");
|
||||
return;
|
||||
}
|
||||
|
||||
ffPrintLogoAndKey(instance, "Packages");
|
||||
|
||||
#define FF_PRINT_PACKAGE(name) \
|
||||
@@ -54,18 +54,13 @@ void ffPrintPackages(FFinstance* instance)
|
||||
#undef FF_PRINT_PACKAGE
|
||||
|
||||
putchar('\n');
|
||||
return;
|
||||
}
|
||||
|
||||
FF_STRBUF_CREATE(packages);
|
||||
|
||||
ffParseFormatString(&packages, &instance->config.packagesFormat, 3,
|
||||
(FFformatarg){FF_FORMAT_ARG_TYPE_UINT, &all},
|
||||
(FFformatarg){FF_FORMAT_ARG_TYPE_UINT, &pacman},
|
||||
(FFformatarg){FF_FORMAT_ARG_TYPE_UINT, &flatpak}
|
||||
);
|
||||
|
||||
ffPrintLogoAndKey(instance, "Packages");
|
||||
ffStrbufPutTo(&packages, stdout);
|
||||
ffStrbufDestroy(&packages);
|
||||
else
|
||||
{
|
||||
ffPrintFormatString(instance, "Packages", &instance->config.packagesFormat, 3,
|
||||
(FFformatarg){FF_FORMAT_ARG_TYPE_UINT, &all},
|
||||
(FFformatarg){FF_FORMAT_ARG_TYPE_UINT, &pacman},
|
||||
(FFformatarg){FF_FORMAT_ARG_TYPE_UINT, &flatpak}
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -85,21 +85,16 @@ void ffPrintTerminal(FFinstance* instance)
|
||||
ffPrintError(instance, "Terminal", instance->state.terminal.error);
|
||||
return;
|
||||
}
|
||||
|
||||
ffPrintLogoAndKey(instance, "Terminal");
|
||||
|
||||
if(instance->config.terminalFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, "Terminal");
|
||||
ffStrbufPutTo(&instance->state.terminal.value, stdout);
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_STRBUF_CREATE(terminal);
|
||||
|
||||
ffParseFormatString(&terminal, &instance->config.terminalFormat, 1,
|
||||
ffPrintFormatString(instance, "Terminal", &instance->config.terminalFormat, 1,
|
||||
(FFformatarg){FF_FORMAT_ARG_TYPE_STRBUF, &instance->state.terminal.value}
|
||||
);
|
||||
|
||||
ffStrbufPutTo(&terminal, stdout);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,22 +2,16 @@
|
||||
|
||||
static void printTerminalFont(FFinstance* instance, char* font)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, "Terminal font");
|
||||
|
||||
if(instance->config.termFontFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, "Terminal font");
|
||||
puts(font);
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_STRBUF_CREATE(termfont);
|
||||
|
||||
ffParseFormatString(&termfont, &instance->config.termFontFormat, 1,
|
||||
ffPrintFormatString(instance, "Terminal font", &instance->config.termFontFormat, 1,
|
||||
(FFformatarg){FF_FORMAT_ARG_TYPE_STRING, font}
|
||||
);
|
||||
|
||||
ffStrbufPutTo(&termfont, stdout);
|
||||
ffStrbufDestroy(&termfont);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-8
@@ -23,10 +23,10 @@ void ffPrintTheme(FFinstance* instance)
|
||||
FF_STRBUF_CREATE(gtkPretty);
|
||||
ffFormatGtkPretty(>kPretty, gtk2, gtk3, gtk4);
|
||||
|
||||
ffPrintLogoAndKey(instance, "Theme");
|
||||
|
||||
if(instance->config.themeFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, "Theme");
|
||||
|
||||
if(plasma[0] != '\0')
|
||||
printf("%s [Plasma], ", plasma);
|
||||
|
||||
@@ -34,17 +34,12 @@ void ffPrintTheme(FFinstance* instance)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_STRBUF_CREATE(theme);
|
||||
|
||||
ffParseFormatString(&theme, &instance->config.themeFormat, 5,
|
||||
ffPrintFormatString(instance, "Theme", &instance->config.themeFormat, 5,
|
||||
(FFformatarg){FF_FORMAT_ARG_TYPE_STRING, plasma},
|
||||
(FFformatarg){FF_FORMAT_ARG_TYPE_STRING, gtk2},
|
||||
(FFformatarg){FF_FORMAT_ARG_TYPE_STRING, gtk3},
|
||||
(FFformatarg){FF_FORMAT_ARG_TYPE_STRING, gtk4},
|
||||
(FFformatarg){FF_FORMAT_ARG_TYPE_STRBUF, >kPretty}
|
||||
);
|
||||
|
||||
ffStrbufPutTo(&theme, stdout);
|
||||
ffStrbufDestroy(&theme);
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
void ffPrintUptime(FFinstance* instance)
|
||||
{
|
||||
|
||||
uint32_t days = instance->state.sysinfo.uptime / 86400;
|
||||
uint32_t hours = (instance->state.sysinfo.uptime - (days * 86400)) / 3600;
|
||||
uint32_t minutes = (instance->state.sysinfo.uptime - (days * 86400) - (hours * 3600)) / 60;
|
||||
@@ -29,17 +28,11 @@ void ffPrintUptime(FFinstance* instance)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_STRBUF_CREATE(uptime);
|
||||
|
||||
ffParseFormatString(&uptime, &instance->config.uptimeFormat, 4,
|
||||
ffPrintFormatString(instance, "Uptime", &instance->config.uptimeFormat, 4,
|
||||
(FFformatarg){FF_FORMAT_ARG_TYPE_UINT, &days},
|
||||
(FFformatarg){FF_FORMAT_ARG_TYPE_UINT, &hours},
|
||||
(FFformatarg){FF_FORMAT_ARG_TYPE_UINT, &minutes},
|
||||
(FFformatarg){FF_FORMAT_ARG_TYPE_UINT, &seconds}
|
||||
);
|
||||
|
||||
ffPrintLogoAndKey(instance, "Uptime");
|
||||
ffStrbufPutTo(&uptime, stdout);
|
||||
ffStrbufDestroy(&uptime);
|
||||
}
|
||||
}
|
||||
+7
-13
@@ -43,28 +43,22 @@ void ffPrintWM(FFinstance* instance)
|
||||
|
||||
closedir(proc);
|
||||
|
||||
if(!found)
|
||||
{
|
||||
ffPrintError(instance, "WM", "No process name matches the name of known display managers");
|
||||
return;
|
||||
}
|
||||
|
||||
if(instance->config.wmFormat.length == 0)
|
||||
{
|
||||
if(!found)
|
||||
{
|
||||
ffPrintError(instance, "WM", "No process name matches the name of known display managers");
|
||||
return;
|
||||
}
|
||||
|
||||
ffPrintLogoAndKey(instance, "WM");
|
||||
ffStrbufPutTo(&name, stdout);
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_STRBUF_CREATE(wm);
|
||||
|
||||
ffParseFormatString(&wm, &instance->config.wmFormat, 1,
|
||||
ffPrintFormatString(instance, "WM", &instance->config.wmFormat, 1,
|
||||
(FFformatarg){FF_FORMAT_ARG_TYPE_STRBUF, &name}
|
||||
);
|
||||
|
||||
ffPrintLogoAndKey(instance, "WM");
|
||||
ffStrbufPutTo(&wm, stdout);
|
||||
ffStrbufDestroy(&wm);
|
||||
}
|
||||
|
||||
ffStrbufDestroy(&name);
|
||||
|
||||
Reference in New Issue
Block a user