mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-30 00:37:23 +01:00
@@ -27,17 +27,6 @@ static void printBattery(FFBatteryOptions* options, FFBatteryResult* result, uin
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
uint32_t timeRemaining = result->timeRemaining < 0 ? 0 : (uint32_t) result->timeRemaining;
|
||||
|
||||
uint32_t seconds = timeRemaining % 60;
|
||||
timeRemaining /= 60;
|
||||
uint32_t minutes = timeRemaining % 60;
|
||||
timeRemaining /= 60;
|
||||
uint32_t hours = timeRemaining % 24;
|
||||
timeRemaining /= 24;
|
||||
uint32_t days = timeRemaining;
|
||||
|
||||
FFPercentageTypeFlags percentType = options->percent.type == 0 ? instance.config.display.percentType : options->percent.type;
|
||||
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
@@ -70,7 +59,7 @@ static void printBattery(FFBatteryOptions* options, FFBatteryResult* result, uin
|
||||
if(str.length > 0)
|
||||
ffStrbufAppendS(&str, " (");
|
||||
|
||||
ffParseDuration(days, hours, minutes, seconds, &str);
|
||||
ffParseDuration((uint32_t) result->timeRemaining, &str);
|
||||
ffStrbufAppendS(&str, " remaining)");
|
||||
}
|
||||
}
|
||||
@@ -95,6 +84,15 @@ static void printBattery(FFBatteryOptions* options, FFBatteryResult* result, uin
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32_t timeRemaining = result->timeRemaining < 0 ? 0 : (uint32_t) result->timeRemaining;
|
||||
uint32_t seconds = timeRemaining % 60;
|
||||
timeRemaining /= 60;
|
||||
uint32_t minutes = timeRemaining % 60;
|
||||
timeRemaining /= 60;
|
||||
uint32_t hours = timeRemaining % 24;
|
||||
timeRemaining /= 24;
|
||||
uint32_t days = timeRemaining;
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY capacityNum = ffStrbufCreate();
|
||||
if(percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
|
||||
ffPercentAppendNum(&capacityNum, result->capacity, options->percent, false, &options->moduleArgs);
|
||||
|
||||
+12
-12
@@ -7,7 +7,7 @@
|
||||
|
||||
void ffPrintUptime(FFUptimeOptions* options)
|
||||
{
|
||||
FFUptimeResult result;
|
||||
FFUptimeResult result = {};
|
||||
|
||||
const char* error = ffDetectUptime(&result);
|
||||
|
||||
@@ -19,26 +19,26 @@ void ffPrintUptime(FFUptimeOptions* options)
|
||||
|
||||
uint64_t uptime = result.uptime;
|
||||
|
||||
uint32_t milliseconds = (uint32_t) (uptime % 1000);
|
||||
uptime /= 1000;
|
||||
uint32_t seconds = (uint32_t) (uptime % 60);
|
||||
uptime /= 60;
|
||||
uint32_t minutes = (uint32_t) (uptime % 60);
|
||||
uptime /= 60;
|
||||
uint32_t hours = (uint32_t) (uptime % 24);
|
||||
uptime /= 24;
|
||||
uint32_t days = (uint32_t) uptime;
|
||||
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(FF_UPTIME_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT);
|
||||
FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate();
|
||||
ffParseDuration(days, hours, minutes, seconds, &buffer);
|
||||
ffParseDuration((uptime + 500) / 1000, &buffer);
|
||||
|
||||
ffStrbufPutTo(&buffer, stdout);
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32_t milliseconds = (uint32_t) (uptime % 1000);
|
||||
uptime /= 1000;
|
||||
uint32_t seconds = (uint32_t) (uptime % 60);
|
||||
uptime /= 60;
|
||||
uint32_t minutes = (uint32_t) (uptime % 60);
|
||||
uptime /= 60;
|
||||
uint32_t hours = (uint32_t) (uptime % 24);
|
||||
uptime /= 24;
|
||||
uint32_t days = (uint32_t) uptime;
|
||||
|
||||
FF_PRINT_FORMAT_CHECKED(FF_UPTIME_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(days, "days"),
|
||||
FF_FORMAT_ARG(hours, "hours"),
|
||||
|
||||
Reference in New Issue
Block a user