Merge pull request #891 from danieldg/temp-tooltip

Add "tooltip-format" to temperature module
This commit is contained in:
Alex 2021-01-18 12:01:34 +01:00 committed by GitHub
commit a25cf4d188
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 0 deletions

View File

@ -50,6 +50,11 @@ Addressed by *temperature*
typeof: array ++
Based on the current temperature (Celsius) and *critical-threshold* if available, the corresponding icon gets selected. The order is *low* to *high*.
*tooltip-format*: ++
typeof: string ++
default: {temperatureC}°C ++
The format for the tooltip
*rotate*: ++
typeof: integer ++
Positive value to rotate the text label.

View File

@ -40,6 +40,16 @@ auto waybar::modules::Temperature::update() -> void {
fmt::arg("temperatureF", temperature_f),
fmt::arg("temperatureK", temperature_k),
fmt::arg("icon", getIcon(temperature_c, "", max_temp))));
if (tooltipEnabled()) {
std::string tooltip_format = "{temperatureC}°C";
if (config_["tooltip-format"].isString()) {
tooltip_format = config_["tooltip-format"].asString();
}
label_.set_tooltip_text(fmt::format(tooltip_format,
fmt::arg("temperatureC", temperature_c),
fmt::arg("temperatureF", temperature_f),
fmt::arg("temperatureK", temperature_k)));
}
// Call parent update
ALabel::update();
}