mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-11-02 03:14:15 +01:00
dont print line if format evaluates to an empty string
This commit is contained in:
+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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user