mirror of
https://github.com/rad4day/Waybar.git
synced 2025-07-13 22:52:30 +02:00
modules/power_profiles_daemon: add custom format from config
We move to a single icon label format to save space on the bar. We still display the profile name and the driver in the tooltip.
This commit is contained in:
@ -17,6 +17,18 @@ namespace waybar::modules {
|
||||
|
||||
PowerProfilesDaemon::PowerProfilesDaemon(const std::string& id, const Json::Value& config)
|
||||
: ALabel(config, "power-profiles-daemon", id, "{profile}", 0, false, true) {
|
||||
if (config_["format"].isString()) {
|
||||
format_ = config_["format"].asString();
|
||||
} else {
|
||||
format_ = "{icon}";
|
||||
}
|
||||
|
||||
if (config_["tooltip-format"].isString()) {
|
||||
tooltipFormat_ = config_["tooltip-format"].asString();
|
||||
} else {
|
||||
tooltipFormat_ = "Power profile: {profile}\nDriver: {driver}";
|
||||
}
|
||||
|
||||
// NOTE: the DBus adresses are under migration. They should be
|
||||
// changed to org.freedesktop.UPower.PowerProfiles at some point.
|
||||
//
|
||||
@ -110,9 +122,11 @@ auto PowerProfilesDaemon::update() -> void {
|
||||
// Set label
|
||||
fmt::dynamic_format_arg_store<fmt::format_context> store;
|
||||
store.push_back(fmt::arg("profile", profile.name));
|
||||
label_.set_markup(fmt::vformat("⚡ {profile}", store));
|
||||
store.push_back(fmt::arg("driver", profile.driver));
|
||||
store.push_back(fmt::arg("icon", getIcon(0, profile.name)));
|
||||
label_.set_markup(fmt::vformat(format_, store));
|
||||
if (tooltipEnabled()) {
|
||||
label_.set_tooltip_text(fmt::format("Driver: {}", profile.driver));
|
||||
label_.set_tooltip_text(fmt::vformat(tooltipFormat_, store));
|
||||
}
|
||||
|
||||
// Set CSS class
|
||||
|
Reference in New Issue
Block a user