Merge pull request #455 from lolzballs/master
Add configurable time display for battery modulepull/456/head
commit
e43b63ff02
|
@ -32,6 +32,11 @@ The *battery* module displays the current capacity and state (eg. charging) of y
|
||||||
default: {capacity}% ++
|
default: {capacity}% ++
|
||||||
The format, how the time should be displayed.
|
The format, how the time should be displayed.
|
||||||
|
|
||||||
|
*format-time* ++
|
||||||
|
typeof: string ++
|
||||||
|
default: {H} h {M} min ++
|
||||||
|
The format, how the time should be displayed.
|
||||||
|
|
||||||
*format-icons*
|
*format-icons*
|
||||||
typeof: array/object
|
typeof: array/object
|
||||||
Based on the current capacity, the corresponding icon gets selected. ++
|
Based on the current capacity, the corresponding icon gets selected. ++
|
||||||
|
@ -78,6 +83,14 @@ The *battery* module displays the current capacity and state (eg. charging) of y
|
||||||
|
|
||||||
*{time}*: Estimate of time until full or empty. Note that this is based on the power draw at the last refresh time, not an average.
|
*{time}*: Estimate of time until full or empty. Note that this is based on the power draw at the last refresh time, not an average.
|
||||||
|
|
||||||
|
# TIME FORMAT
|
||||||
|
|
||||||
|
The *battery* module allows you to define how time should be formatted via *format-time*.
|
||||||
|
|
||||||
|
The two arguments are:
|
||||||
|
*{H}*: Hours
|
||||||
|
*{M}*: Minutes
|
||||||
|
|
||||||
# CUSTOM FORMATS
|
# CUSTOM FORMATS
|
||||||
|
|
||||||
The *battery* module allows to define custom formats based on up to two factors. The best fitting format will be selected.
|
The *battery* module allows to define custom formats based on up to two factors. The best fitting format will be selected.
|
||||||
|
|
|
@ -141,7 +141,11 @@ const std::string waybar::modules::Battery::formatTimeRemaining(float hoursRemai
|
||||||
hoursRemaining = std::fabs(hoursRemaining);
|
hoursRemaining = std::fabs(hoursRemaining);
|
||||||
uint16_t full_hours = static_cast<uint16_t>(hoursRemaining);
|
uint16_t full_hours = static_cast<uint16_t>(hoursRemaining);
|
||||||
uint16_t minutes = static_cast<uint16_t>(60 * (hoursRemaining - full_hours));
|
uint16_t minutes = static_cast<uint16_t>(60 * (hoursRemaining - full_hours));
|
||||||
return std::to_string(full_hours) + " h " + std::to_string(minutes) + " min";
|
auto format = std::string("{H} h {M} min");
|
||||||
|
if (config_["format-time"].isString()) {
|
||||||
|
format = config_["format-time"].asString();
|
||||||
|
}
|
||||||
|
return fmt::format(format, fmt::arg("H", full_hours), fmt::arg("M", minutes));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto waybar::modules::Battery::update() -> void {
|
auto waybar::modules::Battery::update() -> void {
|
||||||
|
|
Loading…
Reference in New Issue