mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
feat(states): add getState to other percent based modules
This commit is contained in:
parent
3bac96945c
commit
5f0a3063d1
@ -181,6 +181,7 @@ auto waybar::modules::Backlight::update() -> void {
|
|||||||
const auto percent = best->get_max() == 0 ? 100 : best->get_actual() * 100 / best->get_max();
|
const auto percent = best->get_max() == 0 ? 100 : best->get_actual() * 100 / best->get_max();
|
||||||
label_.set_markup(fmt::format(
|
label_.set_markup(fmt::format(
|
||||||
format_, fmt::arg("percent", std::to_string(percent)), fmt::arg("icon", getIcon(percent))));
|
format_, fmt::arg("percent", std::to_string(percent)), fmt::arg("icon", getIcon(percent))));
|
||||||
|
getState(percent);
|
||||||
} else {
|
} else {
|
||||||
if (!previous_best_.has_value()) {
|
if (!previous_best_.has_value()) {
|
||||||
return;
|
return;
|
||||||
|
@ -20,6 +20,7 @@ auto waybar::modules::Cpu::update() -> void {
|
|||||||
label_.set_tooltip_text(tooltip);
|
label_.set_tooltip_text(tooltip);
|
||||||
}
|
}
|
||||||
label_.set_markup(fmt::format(format_, fmt::arg("load", cpu_load), fmt::arg("usage", cpu_usage)));
|
label_.set_markup(fmt::format(format_, fmt::arg("load", cpu_load), fmt::arg("usage", cpu_usage)));
|
||||||
|
getState(cpu_usage);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t waybar::modules::Cpu::getCpuLoad() {
|
uint16_t waybar::modules::Cpu::getCpuLoad() {
|
||||||
|
@ -16,6 +16,7 @@ auto waybar::modules::Memory::update() -> void {
|
|||||||
parseMeminfo();
|
parseMeminfo();
|
||||||
if (memtotal_ > 0 && memfree_ >= 0) {
|
if (memtotal_ > 0 && memfree_ >= 0) {
|
||||||
int used_ram_percentage = 100 * (memtotal_ - memfree_) / memtotal_;
|
int used_ram_percentage = 100 * (memtotal_ - memfree_) / memtotal_;
|
||||||
|
getState(used_ram_percentage);
|
||||||
label_.set_markup(fmt::format(format_, used_ram_percentage));
|
label_.set_markup(fmt::format(format_, used_ram_percentage));
|
||||||
auto used_ram_gigabytes = (memtotal_ - memfree_) / std::pow(1024, 2);
|
auto used_ram_gigabytes = (memtotal_ - memfree_) / std::pow(1024, 2);
|
||||||
if (tooltipEnabled()) {
|
if (tooltipEnabled()) {
|
||||||
|
@ -170,6 +170,7 @@ auto waybar::modules::Network::update() -> void {
|
|||||||
if (!alt_) {
|
if (!alt_) {
|
||||||
format_ = default_format_;
|
format_ = default_format_;
|
||||||
}
|
}
|
||||||
|
getState(signal_strength_);
|
||||||
auto text = fmt::format(format_,
|
auto text = fmt::format(format_,
|
||||||
fmt::arg("essid", essid_),
|
fmt::arg("essid", essid_),
|
||||||
fmt::arg("signaldBm", signal_strength_dbm_),
|
fmt::arg("signaldBm", signal_strength_dbm_),
|
||||||
|
@ -202,6 +202,7 @@ auto waybar::modules::Pulseaudio::update() -> void {
|
|||||||
}
|
}
|
||||||
label_.set_markup(fmt::format(
|
label_.set_markup(fmt::format(
|
||||||
format, fmt::arg("volume", volume_), fmt::arg("icon", getIcon(volume_, getPortIcon()))));
|
format, fmt::arg("volume", volume_), fmt::arg("icon", getIcon(volume_, getPortIcon()))));
|
||||||
|
getState(volume_);
|
||||||
if (tooltipEnabled()) {
|
if (tooltipEnabled()) {
|
||||||
label_.set_tooltip_text(desc_);
|
label_.set_tooltip_text(desc_);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user