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.pull/2971/head
parent
162b41c4d0
commit
61fed6a214
|
@ -32,6 +32,9 @@ class PowerProfilesDaemon : public ALabel {
|
||||||
std::vector<Profile>::iterator activeProfile_;
|
std::vector<Profile>::iterator activeProfile_;
|
||||||
// Current CSS class applied to the label
|
// Current CSS class applied to the label
|
||||||
std::string currentStyle_;
|
std::string currentStyle_;
|
||||||
|
// Format strings
|
||||||
|
std::string labelFormat_;
|
||||||
|
std::string tooltipFormat_;
|
||||||
// DBus Proxy used to track the current active profile
|
// DBus Proxy used to track the current active profile
|
||||||
Glib::RefPtr<Gio::DBus::Proxy> powerProfilesProxy_;
|
Glib::RefPtr<Gio::DBus::Proxy> powerProfilesProxy_;
|
||||||
sigc::connection powerProfileChangeSignal_;
|
sigc::connection powerProfileChangeSignal_;
|
||||||
|
|
|
@ -148,6 +148,17 @@
|
||||||
"battery#bat2": {
|
"battery#bat2": {
|
||||||
"bat": "BAT2"
|
"bat": "BAT2"
|
||||||
},
|
},
|
||||||
|
"power_profiles_daemon": {
|
||||||
|
"format": "{icon}",
|
||||||
|
"tooltip-format": "Power profile: {profile}\nDriver: {driver}",
|
||||||
|
"tooltip": true,
|
||||||
|
"format-icons": {
|
||||||
|
"default": "",
|
||||||
|
"performance": "",
|
||||||
|
"balanced": "",
|
||||||
|
"power-saver": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
"network": {
|
"network": {
|
||||||
// "interface": "wlp2*", // (Optional) To force the use of this interface
|
// "interface": "wlp2*", // (Optional) To force the use of this interface
|
||||||
"format-wifi": "{essid} ({signalStrength}%) ",
|
"format-wifi": "{essid} ({signalStrength}%) ",
|
||||||
|
|
|
@ -17,6 +17,18 @@ namespace waybar::modules {
|
||||||
|
|
||||||
PowerProfilesDaemon::PowerProfilesDaemon(const std::string& id, const Json::Value& config)
|
PowerProfilesDaemon::PowerProfilesDaemon(const std::string& id, const Json::Value& config)
|
||||||
: ALabel(config, "power-profiles-daemon", id, "{profile}", 0, false, true) {
|
: 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
|
// NOTE: the DBus adresses are under migration. They should be
|
||||||
// changed to org.freedesktop.UPower.PowerProfiles at some point.
|
// changed to org.freedesktop.UPower.PowerProfiles at some point.
|
||||||
//
|
//
|
||||||
|
@ -110,9 +122,11 @@ auto PowerProfilesDaemon::update() -> void {
|
||||||
// Set label
|
// Set label
|
||||||
fmt::dynamic_format_arg_store<fmt::format_context> store;
|
fmt::dynamic_format_arg_store<fmt::format_context> store;
|
||||||
store.push_back(fmt::arg("profile", profile.name));
|
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()) {
|
if (tooltipEnabled()) {
|
||||||
label_.set_tooltip_text(fmt::format("Driver: {}", profile.driver));
|
label_.set_tooltip_text(fmt::vformat(tooltipFormat_, store));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set CSS class
|
// Set CSS class
|
||||||
|
|
Loading…
Reference in New Issue