mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-11-08 14:10:11 +01:00
format options for every output!
This commit is contained in:
+25
-7
@@ -12,14 +12,32 @@ void ffPrintDisk(FFinstance* instance)
|
||||
return;
|
||||
}
|
||||
|
||||
const uint32_t GB = (1024 * 1024) * 1024;
|
||||
uint32_t GB = (1024 * 1024) * 1024;
|
||||
|
||||
const uint32_t total = (fs.f_blocks * fs.f_frsize) / GB;
|
||||
const uint32_t available = (fs.f_bfree * fs.f_frsize) / GB;
|
||||
const uint32_t used = total - available;
|
||||
const uint32_t percentage = (used / (double) total) * 100.0;
|
||||
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;
|
||||
uint8_t percentage = (used / (double) total) * 100.0;
|
||||
|
||||
|
||||
ffPrintLogoAndKey(instance, "Disk (/)");
|
||||
printf("%uGB / %uGB (%u%%)\n", used, total, percentage);
|
||||
|
||||
if(ffStrbufIsEmpty(&instance->config.diskFormat))
|
||||
{
|
||||
printf("%uGB / %uGB (%u%%)\n", used, total, percentage);
|
||||
}
|
||||
else
|
||||
{
|
||||
FFstrbuf disk;
|
||||
ffStrbufInit(&disk);
|
||||
|
||||
ffParseFormatString(&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}
|
||||
);
|
||||
|
||||
ffStrbufWriteTo(&disk, stdout);
|
||||
putchar('\n');
|
||||
ffStrbufDestroy(&disk);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user