mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 10:52:08 +02:00
Uptime / Battery: add formatted duration string in custom format
This commit is contained in:
@@ -101,6 +101,9 @@ static void printBattery(FFBatteryOptions* options, FFBatteryResult* result, uin
|
||||
ffPercentAppendBar(&capacityBar, result->capacity, options->percent, &options->moduleArgs);
|
||||
FF_STRBUF_AUTO_DESTROY tempStr = ffStrbufCreate();
|
||||
ffTempsAppendNum(result->temperature, &tempStr, options->tempConfig, &options->moduleArgs);
|
||||
FF_STRBUF_AUTO_DESTROY timeStr = ffStrbufCreate();
|
||||
if (result->timeRemaining > 0)
|
||||
ffDurationAppendNum((uint32_t) result->timeRemaining, &timeStr);
|
||||
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(result->manufacturer, "manufacturer"),
|
||||
@@ -117,6 +120,7 @@ static void printBattery(FFBatteryOptions* options, FFBatteryResult* result, uin
|
||||
FF_FORMAT_ARG(hours, "time-hours"),
|
||||
FF_FORMAT_ARG(minutes, "time-minutes"),
|
||||
FF_FORMAT_ARG(seconds, "time-seconds"),
|
||||
FF_FORMAT_ARG(result->timeRemaining, "time-formatted"),
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -254,6 +258,8 @@ void ffGenerateBatteryJsonResult(FFBatteryOptions* options, yyjson_mut_doc* doc,
|
||||
yyjson_mut_obj_add_uint(doc, obj, "cycleCount", battery->cycleCount);
|
||||
if (battery->timeRemaining > 0)
|
||||
yyjson_mut_obj_add_int(doc, obj, "timeRemaining", battery->timeRemaining);
|
||||
else
|
||||
yyjson_mut_obj_add_null(doc, obj, "timeRemaining");
|
||||
}
|
||||
|
||||
FF_LIST_FOR_EACH(FFBatteryResult, battery, results)
|
||||
|
||||
Reference in New Issue
Block a user