mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
fix: compilation errors with cpp_std=c++20
There were two main issues with fmtlib and C++20 mode: - `fmt::format` defaults to compile-time argument checking and requires using `fmt::runtime(format_string)` to bypass that. - `std::format` implementation introduces conflicting declarations and we have to specify the namespace for all `format`/`format_to` calls.
This commit is contained in:
parent
67efe1af89
commit
ea17a66dfc
@ -4,6 +4,7 @@
|
|||||||
#include <gtkmm/button.h>
|
#include <gtkmm/button.h>
|
||||||
#include <gtkmm/label.h>
|
#include <gtkmm/label.h>
|
||||||
|
|
||||||
|
#include <string_view>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
#include "AModule.hpp"
|
#include "AModule.hpp"
|
||||||
@ -21,7 +22,9 @@ class Workspaces : public AModule, public sigc::trackable {
|
|||||||
auto update() -> void;
|
auto update() -> void;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static inline const std::string workspace_switch_cmd_ = "workspace {} \"{}\"";
|
static constexpr std::string_view workspace_switch_cmd_ = "workspace {} \"{}\"";
|
||||||
|
static constexpr std::string_view persistent_workspace_switch_cmd_ =
|
||||||
|
R"(workspace {} "{}"; move workspace to output "{}"; workspace {} "{}")";
|
||||||
|
|
||||||
static int convertWorkspaceNameToNum(std::string name);
|
static int convertWorkspaceNameToNum(std::string name);
|
||||||
|
|
||||||
|
@ -66,9 +66,9 @@ struct formatter<pow_format> {
|
|||||||
std::string string;
|
std::string string;
|
||||||
switch (spec) {
|
switch (spec) {
|
||||||
case '>':
|
case '>':
|
||||||
return format_to(ctx.out(), "{:>{}}", fmt::format("{}", s), max_width);
|
return fmt::format_to(ctx.out(), "{:>{}}", fmt::format("{}", s), max_width);
|
||||||
case '<':
|
case '<':
|
||||||
return format_to(ctx.out(), "{:<{}}", fmt::format("{}", s), max_width);
|
return fmt::format_to(ctx.out(), "{:<{}}", fmt::format("{}", s), max_width);
|
||||||
case '=':
|
case '=':
|
||||||
format = "{coefficient:<{number_width}.1f}{padding}{prefix}{unit}";
|
format = "{coefficient:<{number_width}.1f}{padding}{prefix}{unit}";
|
||||||
break;
|
break;
|
||||||
@ -77,8 +77,8 @@ struct formatter<pow_format> {
|
|||||||
format = "{coefficient:.1f}{prefix}{unit}";
|
format = "{coefficient:.1f}{prefix}{unit}";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return format_to(
|
return fmt::format_to(
|
||||||
ctx.out(), format, fmt::arg("coefficient", fraction),
|
ctx.out(), fmt::runtime(format), fmt::arg("coefficient", fraction),
|
||||||
fmt::arg("number_width", number_width),
|
fmt::arg("number_width", number_width),
|
||||||
fmt::arg("prefix", std::string() + units[pow] + ((s.binary_ && pow) ? "i" : "")),
|
fmt::arg("prefix", std::string() + units[pow] + ((s.binary_ && pow) ? "i" : "")),
|
||||||
fmt::arg("unit", s.unit_),
|
fmt::arg("unit", s.unit_),
|
||||||
|
@ -48,13 +48,13 @@ struct UdevMonitorDeleter {
|
|||||||
|
|
||||||
void check_eq(int rc, int expected, const char *message = "eq, rc was: ") {
|
void check_eq(int rc, int expected, const char *message = "eq, rc was: ") {
|
||||||
if (rc != expected) {
|
if (rc != expected) {
|
||||||
throw std::runtime_error(fmt::format(message, rc));
|
throw std::runtime_error(fmt::format(fmt::runtime(message), rc));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void check_neq(int rc, int bad_rc, const char *message = "neq, rc was: ") {
|
void check_neq(int rc, int bad_rc, const char *message = "neq, rc was: ") {
|
||||||
if (rc == bad_rc) {
|
if (rc == bad_rc) {
|
||||||
throw std::runtime_error(fmt::format(message, rc));
|
throw std::runtime_error(fmt::format(fmt::runtime(message), rc));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ void check0(int rc, const char *message = "rc wasn't 0") { check_eq(rc, 0, messa
|
|||||||
|
|
||||||
void check_gte(int rc, int gte, const char *message = "rc was: ") {
|
void check_gte(int rc, int gte, const char *message = "rc was: ") {
|
||||||
if (rc < gte) {
|
if (rc < gte) {
|
||||||
throw std::runtime_error(fmt::format(message, rc));
|
throw std::runtime_error(fmt::format(fmt::runtime(message), rc));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,7 +181,8 @@ auto waybar::modules::Backlight::update() -> void {
|
|||||||
event_box_.show();
|
event_box_.show();
|
||||||
const uint8_t percent =
|
const uint8_t percent =
|
||||||
best->get_max() == 0 ? 100 : round(best->get_actual() * 100.0f / best->get_max());
|
best->get_max() == 0 ? 100 : round(best->get_actual() * 100.0f / best->get_max());
|
||||||
label_.set_markup(fmt::format(format_, fmt::arg("percent", std::to_string(percent)),
|
label_.set_markup(fmt::format(fmt::runtime(format_),
|
||||||
|
fmt::arg("percent", std::to_string(percent)),
|
||||||
fmt::arg("icon", getIcon(percent))));
|
fmt::arg("icon", getIcon(percent))));
|
||||||
getState(percent);
|
getState(percent);
|
||||||
} else {
|
} else {
|
||||||
|
@ -604,7 +604,7 @@ const std::string waybar::modules::Battery::formatTimeRemaining(float hoursRemai
|
|||||||
format = config_["format-time"].asString();
|
format = config_["format-time"].asString();
|
||||||
}
|
}
|
||||||
std::string zero_pad_minutes = fmt::format("{:02d}", minutes);
|
std::string zero_pad_minutes = fmt::format("{:02d}", minutes);
|
||||||
return fmt::format(format, fmt::arg("H", full_hours), fmt::arg("M", minutes),
|
return fmt::format(fmt::runtime(format), fmt::arg("H", full_hours), fmt::arg("M", minutes),
|
||||||
fmt::arg("m", zero_pad_minutes));
|
fmt::arg("m", zero_pad_minutes));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -644,7 +644,8 @@ auto waybar::modules::Battery::update() -> void {
|
|||||||
} else if (config_["tooltip-format"].isString()) {
|
} else if (config_["tooltip-format"].isString()) {
|
||||||
tooltip_format = config_["tooltip-format"].asString();
|
tooltip_format = config_["tooltip-format"].asString();
|
||||||
}
|
}
|
||||||
label_.set_tooltip_text(fmt::format(tooltip_format, fmt::arg("timeTo", tooltip_text_default),
|
label_.set_tooltip_text(fmt::format(fmt::runtime(tooltip_format),
|
||||||
|
fmt::arg("timeTo", tooltip_text_default),
|
||||||
fmt::arg("power", power), fmt::arg("capacity", capacity),
|
fmt::arg("power", power), fmt::arg("capacity", capacity),
|
||||||
fmt::arg("time", time_remaining_formatted)));
|
fmt::arg("time", time_remaining_formatted)));
|
||||||
}
|
}
|
||||||
@ -665,9 +666,9 @@ auto waybar::modules::Battery::update() -> void {
|
|||||||
} else {
|
} else {
|
||||||
event_box_.show();
|
event_box_.show();
|
||||||
auto icons = std::vector<std::string>{status + "-" + state, status, state};
|
auto icons = std::vector<std::string>{status + "-" + state, status, state};
|
||||||
label_.set_markup(fmt::format(format, fmt::arg("capacity", capacity), fmt::arg("power", power),
|
label_.set_markup(fmt::format(
|
||||||
fmt::arg("icon", getIcon(capacity, icons)),
|
fmt::runtime(format), fmt::arg("capacity", capacity), fmt::arg("power", power),
|
||||||
fmt::arg("time", time_remaining_formatted)));
|
fmt::arg("icon", getIcon(capacity, icons)), fmt::arg("time", time_remaining_formatted)));
|
||||||
}
|
}
|
||||||
// Call parent update
|
// Call parent update
|
||||||
ALabel::update();
|
ALabel::update();
|
||||||
|
@ -206,7 +206,8 @@ auto waybar::modules::Bluetooth::update() -> void {
|
|||||||
state_ = state;
|
state_ = state;
|
||||||
|
|
||||||
label_.set_markup(fmt::format(
|
label_.set_markup(fmt::format(
|
||||||
format_, fmt::arg("status", state_), fmt::arg("num_connections", connected_devices_.size()),
|
fmt::runtime(format_), fmt::arg("status", state_),
|
||||||
|
fmt::arg("num_connections", connected_devices_.size()),
|
||||||
fmt::arg("controller_address", cur_controller_.address),
|
fmt::arg("controller_address", cur_controller_.address),
|
||||||
fmt::arg("controller_address_type", cur_controller_.address_type),
|
fmt::arg("controller_address_type", cur_controller_.address_type),
|
||||||
fmt::arg("controller_alias", cur_controller_.alias),
|
fmt::arg("controller_alias", cur_controller_.alias),
|
||||||
@ -234,7 +235,7 @@ auto waybar::modules::Bluetooth::update() -> void {
|
|||||||
enumerate_format = config_["tooltip-format-enumerate-connected"].asString();
|
enumerate_format = config_["tooltip-format-enumerate-connected"].asString();
|
||||||
}
|
}
|
||||||
ss << fmt::format(
|
ss << fmt::format(
|
||||||
enumerate_format, fmt::arg("device_address", dev.address),
|
fmt::runtime(enumerate_format), fmt::arg("device_address", dev.address),
|
||||||
fmt::arg("device_address_type", dev.address_type),
|
fmt::arg("device_address_type", dev.address_type),
|
||||||
fmt::arg("device_alias", dev.alias), fmt::arg("icon", enumerate_icon),
|
fmt::arg("device_alias", dev.alias), fmt::arg("icon", enumerate_icon),
|
||||||
fmt::arg("device_battery_percentage", dev.battery_percentage.value_or(0)));
|
fmt::arg("device_battery_percentage", dev.battery_percentage.value_or(0)));
|
||||||
@ -247,7 +248,7 @@ auto waybar::modules::Bluetooth::update() -> void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
label_.set_tooltip_text(fmt::format(
|
label_.set_tooltip_text(fmt::format(
|
||||||
tooltip_format, fmt::arg("status", state_),
|
fmt::runtime(tooltip_format), fmt::arg("status", state_),
|
||||||
fmt::arg("num_connections", connected_devices_.size()),
|
fmt::arg("num_connections", connected_devices_.size()),
|
||||||
fmt::arg("controller_address", cur_controller_.address),
|
fmt::arg("controller_address", cur_controller_.address),
|
||||||
fmt::arg("controller_address_type", cur_controller_.address_type),
|
fmt::arg("controller_address_type", cur_controller_.address_type),
|
||||||
|
@ -121,9 +121,9 @@ auto waybar::modules::Clock::update() -> void {
|
|||||||
// As date dep is not fully compatible, prefer fmt
|
// As date dep is not fully compatible, prefer fmt
|
||||||
tzset();
|
tzset();
|
||||||
auto localtime = fmt::localtime(std::chrono::system_clock::to_time_t(now));
|
auto localtime = fmt::localtime(std::chrono::system_clock::to_time_t(now));
|
||||||
text = fmt::format(locale_, format_, localtime);
|
text = fmt::format(locale_, fmt::runtime(format_), localtime);
|
||||||
} else {
|
} else {
|
||||||
text = fmt::format(locale_, format_, ztime);
|
text = fmt::format(locale_, fmt::runtime(format_), ztime);
|
||||||
}
|
}
|
||||||
label_.set_markup(text);
|
label_.set_markup(text);
|
||||||
|
|
||||||
@ -138,7 +138,7 @@ auto waybar::modules::Clock::update() -> void {
|
|||||||
timezoned_time_lines = timezones_text(&now);
|
timezoned_time_lines = timezones_text(&now);
|
||||||
}
|
}
|
||||||
auto tooltip_format = config_["tooltip-format"].asString();
|
auto tooltip_format = config_["tooltip-format"].asString();
|
||||||
text = fmt::format(locale_, tooltip_format, shifted_ztime,
|
text = fmt::format(locale_, fmt::runtime(tooltip_format), shifted_ztime,
|
||||||
fmt::arg(kCalendarPlaceholder.c_str(), calendar_lines),
|
fmt::arg(kCalendarPlaceholder.c_str(), calendar_lines),
|
||||||
fmt::arg(KTimezonedTimeListPlaceholder.c_str(), timezoned_time_lines));
|
fmt::arg(KTimezonedTimeListPlaceholder.c_str(), timezoned_time_lines));
|
||||||
label_.set_tooltip_markup(text);
|
label_.set_tooltip_markup(text);
|
||||||
@ -228,7 +228,7 @@ auto waybar::modules::Clock::calendar_text(const date::zoned_seconds& ztime) ->
|
|||||||
|
|
||||||
/* Print weeknumber on the left for the first row*/
|
/* Print weeknumber on the left for the first row*/
|
||||||
if (weeks_pos == WeeksSide::LEFT) {
|
if (weeks_pos == WeeksSide::LEFT) {
|
||||||
os << fmt::format(fmt_str_weeks_, print_wd) << ' ';
|
os << fmt::format(fmt::runtime(fmt_str_weeks_), print_wd) << ' ';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty_days > 0) {
|
if (empty_days > 0) {
|
||||||
@ -242,7 +242,7 @@ auto waybar::modules::Clock::calendar_text(const date::zoned_seconds& ztime) ->
|
|||||||
os << ' ';
|
os << ' ';
|
||||||
} else if (unsigned(d) != 1) {
|
} else if (unsigned(d) != 1) {
|
||||||
if (weeks_pos == WeeksSide::RIGHT) {
|
if (weeks_pos == WeeksSide::RIGHT) {
|
||||||
os << ' ' << fmt::format(fmt_str_weeks_, print_wd);
|
os << ' ' << fmt::format(fmt::runtime(fmt_str_weeks_), print_wd);
|
||||||
}
|
}
|
||||||
|
|
||||||
os << '\n';
|
os << '\n';
|
||||||
@ -250,19 +250,19 @@ auto waybar::modules::Clock::calendar_text(const date::zoned_seconds& ztime) ->
|
|||||||
print_wd = (ym / d);
|
print_wd = (ym / d);
|
||||||
|
|
||||||
if (weeks_pos == WeeksSide::LEFT) {
|
if (weeks_pos == WeeksSide::LEFT) {
|
||||||
os << fmt::format(fmt_str_weeks_, print_wd) << ' ';
|
os << fmt::format(fmt::runtime(fmt_str_weeks_), print_wd) << ' ';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (d == curr_day) {
|
if (d == curr_day) {
|
||||||
if (config_["today-format"].isString()) {
|
if (config_["today-format"].isString()) {
|
||||||
auto today_format = config_["today-format"].asString();
|
auto today_format = config_["today-format"].asString();
|
||||||
os << fmt::format(today_format, date::format("%e", d));
|
os << fmt::format(fmt::runtime(today_format), date::format("%e", d));
|
||||||
} else {
|
} else {
|
||||||
os << "<b><u>" << date::format("%e", d) << "</u></b>";
|
os << "<b><u>" << date::format("%e", d) << "</u></b>";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
os << fmt::format(fmt_str_calendar_, date::format("%e", d));
|
os << fmt::format(fmt::runtime(fmt_str_calendar_), date::format("%e", d));
|
||||||
}
|
}
|
||||||
/*Print weeks on the right when the endings with spaces*/
|
/*Print weeks on the right when the endings with spaces*/
|
||||||
if (weeks_pos == WeeksSide::RIGHT && d == last_day) {
|
if (weeks_pos == WeeksSide::RIGHT && d == last_day) {
|
||||||
@ -271,7 +271,7 @@ auto waybar::modules::Clock::calendar_text(const date::zoned_seconds& ztime) ->
|
|||||||
os << std::string(empty_days * 3, ' ');
|
os << std::string(empty_days * 3, ' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
os << ' ' << fmt::format(fmt_str_weeks_, print_wd);
|
os << ' ' << fmt::format(fmt::runtime(fmt_str_weeks_), print_wd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -303,7 +303,8 @@ auto waybar::modules::Clock::weekdays_header(const date::weekday& first_week_day
|
|||||||
res << '\n';
|
res << '\n';
|
||||||
|
|
||||||
if (config_["format-calendar-weekdays"].isString()) {
|
if (config_["format-calendar-weekdays"].isString()) {
|
||||||
os << fmt::format(config_["format-calendar-weekdays"].asString(), res.str());
|
auto weekdays_format = config_["format-calendar-weekdays"].asString();
|
||||||
|
os << fmt::format(fmt::runtime(weekdays_format), res.str());
|
||||||
} else
|
} else
|
||||||
os << res.str();
|
os << res.str();
|
||||||
}
|
}
|
||||||
@ -323,7 +324,7 @@ auto waybar::modules::Clock::timezones_text(std::chrono::system_clock::time_poin
|
|||||||
timezone = date::current_zone();
|
timezone = date::current_zone();
|
||||||
}
|
}
|
||||||
auto ztime = date::zoned_time{timezone, date::floor<std::chrono::seconds>(*now)};
|
auto ztime = date::zoned_time{timezone, date::floor<std::chrono::seconds>(*now)};
|
||||||
os << fmt::format(locale_, format_, ztime) << '\n';
|
os << fmt::format(locale_, fmt::runtime(format_), ztime) << '\n';
|
||||||
}
|
}
|
||||||
return os.str();
|
return os.str();
|
||||||
}
|
}
|
||||||
|
@ -126,7 +126,7 @@ auto waybar::modules::Custom::update() -> void {
|
|||||||
} else {
|
} else {
|
||||||
parseOutputRaw();
|
parseOutputRaw();
|
||||||
}
|
}
|
||||||
auto str = fmt::format(format_, text_, fmt::arg("alt", alt_),
|
auto str = fmt::format(fmt::runtime(format_), text_, fmt::arg("alt", alt_),
|
||||||
fmt::arg("icon", getIcon(percentage_, alt_)),
|
fmt::arg("icon", getIcon(percentage_, alt_)),
|
||||||
fmt::arg("percentage", percentage_));
|
fmt::arg("percentage", percentage_));
|
||||||
if (str.empty()) {
|
if (str.empty()) {
|
||||||
|
@ -58,11 +58,11 @@ auto waybar::modules::Disk::update() -> void {
|
|||||||
event_box_.hide();
|
event_box_.hide();
|
||||||
} else {
|
} else {
|
||||||
event_box_.show();
|
event_box_.show();
|
||||||
label_.set_markup(
|
label_.set_markup(fmt::format(
|
||||||
fmt::format(format, stats.f_bavail * 100 / stats.f_blocks, fmt::arg("free", free),
|
fmt::runtime(format), stats.f_bavail * 100 / stats.f_blocks, fmt::arg("free", free),
|
||||||
fmt::arg("percentage_free", stats.f_bavail * 100 / stats.f_blocks),
|
fmt::arg("percentage_free", stats.f_bavail * 100 / stats.f_blocks), fmt::arg("used", used),
|
||||||
fmt::arg("used", used), fmt::arg("percentage_used", percentage_used),
|
fmt::arg("percentage_used", percentage_used), fmt::arg("total", total),
|
||||||
fmt::arg("total", total), fmt::arg("path", path_)));
|
fmt::arg("path", path_)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tooltipEnabled()) {
|
if (tooltipEnabled()) {
|
||||||
@ -70,11 +70,11 @@ auto waybar::modules::Disk::update() -> void {
|
|||||||
if (config_["tooltip-format"].isString()) {
|
if (config_["tooltip-format"].isString()) {
|
||||||
tooltip_format = config_["tooltip-format"].asString();
|
tooltip_format = config_["tooltip-format"].asString();
|
||||||
}
|
}
|
||||||
label_.set_tooltip_text(
|
label_.set_tooltip_text(fmt::format(
|
||||||
fmt::format(tooltip_format, stats.f_bavail * 100 / stats.f_blocks, fmt::arg("free", free),
|
fmt::runtime(tooltip_format), stats.f_bavail * 100 / stats.f_blocks, fmt::arg("free", free),
|
||||||
fmt::arg("percentage_free", stats.f_bavail * 100 / stats.f_blocks),
|
fmt::arg("percentage_free", stats.f_bavail * 100 / stats.f_blocks), fmt::arg("used", used),
|
||||||
fmt::arg("used", used), fmt::arg("percentage_used", percentage_used),
|
fmt::arg("percentage_used", percentage_used), fmt::arg("total", total),
|
||||||
fmt::arg("total", total), fmt::arg("path", path_)));
|
fmt::arg("path", path_)));
|
||||||
}
|
}
|
||||||
// Call parent update
|
// Call parent update
|
||||||
ALabel::update();
|
ALabel::update();
|
||||||
|
@ -213,14 +213,14 @@ auto Gamemode::update() -> void {
|
|||||||
|
|
||||||
// Tooltip
|
// Tooltip
|
||||||
if (tooltip) {
|
if (tooltip) {
|
||||||
std::string text = fmt::format(tooltip_format, fmt::arg("count", gameCount));
|
std::string text = fmt::format(fmt::runtime(tooltip_format), fmt::arg("count", gameCount));
|
||||||
box_.set_tooltip_text(text);
|
box_.set_tooltip_text(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Label format
|
// Label format
|
||||||
std::string str =
|
std::string str = fmt::format(fmt::runtime(showAltText ? format_alt : format),
|
||||||
fmt::format(showAltText ? format_alt : format, fmt::arg("glyph", useIcon ? "" : glyph),
|
fmt::arg("glyph", useIcon ? "" : glyph),
|
||||||
fmt::arg("count", gameCount > 0 ? std::to_string(gameCount) : ""));
|
fmt::arg("count", gameCount > 0 ? std::to_string(gameCount) : ""));
|
||||||
label_.set_markup(str);
|
label_.set_markup(str);
|
||||||
|
|
||||||
if (useIcon) {
|
if (useIcon) {
|
||||||
|
@ -59,9 +59,9 @@ void Language::onEvent(const std::string& ev) {
|
|||||||
|
|
||||||
if (config_.isMember("format-" + briefName)) {
|
if (config_.isMember("format-" + briefName)) {
|
||||||
const auto propName = "format-" + briefName;
|
const auto propName = "format-" + briefName;
|
||||||
layoutName = fmt::format(format_, config_[propName].asString());
|
layoutName = fmt::format(fmt::runtime(format_), config_[propName].asString());
|
||||||
} else {
|
} else {
|
||||||
layoutName = fmt::format(format_, layoutName);
|
layoutName = fmt::format(fmt::runtime(format_), layoutName);
|
||||||
}
|
}
|
||||||
|
|
||||||
layoutName = waybar::util::sanitize_string(layoutName);
|
layoutName = waybar::util::sanitize_string(layoutName);
|
||||||
@ -92,9 +92,9 @@ void Language::initLanguage() {
|
|||||||
|
|
||||||
if (config_.isMember("format-" + briefName)) {
|
if (config_.isMember("format-" + briefName)) {
|
||||||
const auto propName = "format-" + briefName;
|
const auto propName = "format-" + briefName;
|
||||||
layoutName = fmt::format(format_, config_[propName].asString());
|
layoutName = fmt::format(fmt::runtime(format_), config_[propName].asString());
|
||||||
} else {
|
} else {
|
||||||
layoutName = fmt::format(format_, searcher);
|
layoutName = fmt::format(fmt::runtime(format_), searcher);
|
||||||
}
|
}
|
||||||
|
|
||||||
layoutName = waybar::util::sanitize_string(layoutName);
|
layoutName = waybar::util::sanitize_string(layoutName);
|
||||||
|
@ -34,7 +34,7 @@ auto Submap::update() -> void {
|
|||||||
if (submap_.empty()) {
|
if (submap_.empty()) {
|
||||||
event_box_.hide();
|
event_box_.hide();
|
||||||
} else {
|
} else {
|
||||||
label_.set_markup(fmt::format(format_, submap_));
|
label_.set_markup(fmt::format(fmt::runtime(format_), submap_));
|
||||||
if (tooltipEnabled()) {
|
if (tooltipEnabled()) {
|
||||||
label_.set_tooltip_text(submap_);
|
label_.set_tooltip_text(submap_);
|
||||||
}
|
}
|
||||||
|
@ -40,8 +40,8 @@ auto Window::update() -> void {
|
|||||||
|
|
||||||
if (!format_.empty()) {
|
if (!format_.empty()) {
|
||||||
label_.show();
|
label_.show();
|
||||||
label_.set_markup(
|
label_.set_markup(fmt::format(fmt::runtime(format_),
|
||||||
fmt::format(format_, waybar::util::rewriteTitle(lastView, config_["rewrite"])));
|
waybar::util::rewriteTitle(lastView, config_["rewrite"])));
|
||||||
} else {
|
} else {
|
||||||
label_.hide();
|
label_.hide();
|
||||||
}
|
}
|
||||||
|
@ -63,21 +63,15 @@ auto waybar::modules::IdleInhibitor::update() -> void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string status_text = status ? "activated" : "deactivated";
|
std::string status_text = status ? "activated" : "deactivated";
|
||||||
label_.set_markup(fmt::format(format_, fmt::arg("status", status_text),
|
label_.set_markup(fmt::format(fmt::runtime(format_), fmt::arg("status", status_text),
|
||||||
fmt::arg("icon", getIcon(0, status_text))));
|
fmt::arg("icon", getIcon(0, status_text))));
|
||||||
label_.get_style_context()->add_class(status_text);
|
label_.get_style_context()->add_class(status_text);
|
||||||
if (tooltipEnabled()) {
|
if (tooltipEnabled()) {
|
||||||
label_.set_tooltip_markup(
|
auto config = config_[status ? "tooltip-format-activated" : "tooltip-format-deactivated"];
|
||||||
status ? fmt::format(config_["tooltip-format-activated"].isString()
|
auto tooltip_format = config.isString() ? config.asString() : "{status}";
|
||||||
? config_["tooltip-format-activated"].asString()
|
label_.set_tooltip_markup(fmt::format(fmt::runtime(tooltip_format),
|
||||||
: "{status}",
|
fmt::arg("status", status_text),
|
||||||
fmt::arg("status", status_text),
|
fmt::arg("icon", getIcon(0, status_text))));
|
||||||
fmt::arg("icon", getIcon(0, status_text)))
|
|
||||||
: fmt::format(config_["tooltip-format-deactivated"].isString()
|
|
||||||
? config_["tooltip-format-deactivated"].asString()
|
|
||||||
: "{status}",
|
|
||||||
fmt::arg("status", status_text),
|
|
||||||
fmt::arg("icon", getIcon(0, status_text))));
|
|
||||||
}
|
}
|
||||||
// Call parent update
|
// Call parent update
|
||||||
ALabel::update();
|
ALabel::update();
|
||||||
|
@ -118,7 +118,7 @@ auto Inhibitor::update() -> void {
|
|||||||
std::string status_text = activated() ? "activated" : "deactivated";
|
std::string status_text = activated() ? "activated" : "deactivated";
|
||||||
|
|
||||||
label_.get_style_context()->remove_class(activated() ? "deactivated" : "activated");
|
label_.get_style_context()->remove_class(activated() ? "deactivated" : "activated");
|
||||||
label_.set_markup(fmt::format(format_, fmt::arg("status", status_text),
|
label_.set_markup(fmt::format(fmt::runtime(format_), fmt::arg("status", status_text),
|
||||||
fmt::arg("icon", getIcon(0, status_text))));
|
fmt::arg("icon", getIcon(0, status_text))));
|
||||||
label_.get_style_context()->add_class(status_text);
|
label_.get_style_context()->add_class(status_text);
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ auto JACK::update() -> void {
|
|||||||
} else
|
} else
|
||||||
format = "{load}%";
|
format = "{load}%";
|
||||||
|
|
||||||
label_.set_markup(fmt::format(format, fmt::arg("load", std::round(load_)),
|
label_.set_markup(fmt::format(fmt::runtime(format), fmt::arg("load", std::round(load_)),
|
||||||
fmt::arg("bufsize", bufsize_), fmt::arg("samplerate", samplerate_),
|
fmt::arg("bufsize", bufsize_), fmt::arg("samplerate", samplerate_),
|
||||||
fmt::arg("latency", fmt::format("{:.2f}", latency)),
|
fmt::arg("latency", fmt::format("{:.2f}", latency)),
|
||||||
fmt::arg("xruns", xruns_)));
|
fmt::arg("xruns", xruns_)));
|
||||||
@ -81,9 +81,9 @@ auto JACK::update() -> void {
|
|||||||
std::string tooltip_format = "{bufsize}/{samplerate} {latency}ms";
|
std::string tooltip_format = "{bufsize}/{samplerate} {latency}ms";
|
||||||
if (config_["tooltip-format"].isString()) tooltip_format = config_["tooltip-format"].asString();
|
if (config_["tooltip-format"].isString()) tooltip_format = config_["tooltip-format"].asString();
|
||||||
label_.set_tooltip_text(fmt::format(
|
label_.set_tooltip_text(fmt::format(
|
||||||
tooltip_format, fmt::arg("load", std::round(load_)), fmt::arg("bufsize", bufsize_),
|
fmt::runtime(tooltip_format), fmt::arg("load", std::round(load_)),
|
||||||
fmt::arg("samplerate", samplerate_), fmt::arg("latency", fmt::format("{:.2f}", latency)),
|
fmt::arg("bufsize", bufsize_), fmt::arg("samplerate", samplerate_),
|
||||||
fmt::arg("xruns", xruns_)));
|
fmt::arg("latency", fmt::format("{:.2f}", latency)), fmt::arg("xruns", xruns_)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call parent update
|
// Call parent update
|
||||||
|
@ -278,7 +278,7 @@ auto waybar::modules::KeyboardState::update() -> void {
|
|||||||
};
|
};
|
||||||
for (auto& label_state : label_states) {
|
for (auto& label_state : label_states) {
|
||||||
std::string text;
|
std::string text;
|
||||||
text = fmt::format(label_state.format,
|
text = fmt::format(fmt::runtime(label_state.format),
|
||||||
fmt::arg("icon", label_state.state ? icon_locked_ : icon_unlocked_),
|
fmt::arg("icon", label_state.state ? icon_locked_ : icon_unlocked_),
|
||||||
fmt::arg("name", label_state.name));
|
fmt::arg("name", label_state.name));
|
||||||
label_state.label.set_markup(text);
|
label_state.label.set_markup(text);
|
||||||
|
@ -56,7 +56,8 @@ auto waybar::modules::Memory::update() -> void {
|
|||||||
event_box_.show();
|
event_box_.show();
|
||||||
auto icons = std::vector<std::string>{state};
|
auto icons = std::vector<std::string>{state};
|
||||||
label_.set_markup(fmt::format(
|
label_.set_markup(fmt::format(
|
||||||
format, used_ram_percentage, fmt::arg("icon", getIcon(used_ram_percentage, icons)),
|
fmt::runtime(format), used_ram_percentage,
|
||||||
|
fmt::arg("icon", getIcon(used_ram_percentage, icons)),
|
||||||
fmt::arg("total", total_ram_gigabytes), fmt::arg("swapTotal", total_swap_gigabytes),
|
fmt::arg("total", total_ram_gigabytes), fmt::arg("swapTotal", total_swap_gigabytes),
|
||||||
fmt::arg("percentage", used_ram_percentage),
|
fmt::arg("percentage", used_ram_percentage),
|
||||||
fmt::arg("swapPercentage", used_swap_percentage), fmt::arg("used", used_ram_gigabytes),
|
fmt::arg("swapPercentage", used_swap_percentage), fmt::arg("used", used_ram_gigabytes),
|
||||||
@ -68,8 +69,8 @@ auto waybar::modules::Memory::update() -> void {
|
|||||||
if (config_["tooltip-format"].isString()) {
|
if (config_["tooltip-format"].isString()) {
|
||||||
auto tooltip_format = config_["tooltip-format"].asString();
|
auto tooltip_format = config_["tooltip-format"].asString();
|
||||||
label_.set_tooltip_text(fmt::format(
|
label_.set_tooltip_text(fmt::format(
|
||||||
tooltip_format, used_ram_percentage, fmt::arg("total", total_ram_gigabytes),
|
fmt::runtime(tooltip_format), used_ram_percentage,
|
||||||
fmt::arg("swapTotal", total_swap_gigabytes),
|
fmt::arg("total", total_ram_gigabytes), fmt::arg("swapTotal", total_swap_gigabytes),
|
||||||
fmt::arg("percentage", used_ram_percentage),
|
fmt::arg("percentage", used_ram_percentage),
|
||||||
fmt::arg("swapPercentage", used_swap_percentage), fmt::arg("used", used_ram_gigabytes),
|
fmt::arg("swapPercentage", used_swap_percentage), fmt::arg("used", used_ram_gigabytes),
|
||||||
fmt::arg("swapUsed", used_swap_gigabytes), fmt::arg("avail", available_ram_gigabytes),
|
fmt::arg("swapUsed", used_swap_gigabytes), fmt::arg("avail", available_ram_gigabytes),
|
||||||
|
@ -174,14 +174,14 @@ void waybar::modules::MPD::setLabel() {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
auto text = fmt::format(
|
auto text = fmt::format(
|
||||||
format, fmt::arg("artist", artist.raw()), fmt::arg("albumArtist", album_artist.raw()),
|
fmt::runtime(format), fmt::arg("artist", artist.raw()),
|
||||||
fmt::arg("album", album.raw()), fmt::arg("title", title.raw()), fmt::arg("date", date),
|
fmt::arg("albumArtist", album_artist.raw()), fmt::arg("album", album.raw()),
|
||||||
fmt::arg("volume", volume), fmt::arg("elapsedTime", elapsedTime),
|
fmt::arg("title", title.raw()), fmt::arg("date", date), fmt::arg("volume", volume),
|
||||||
fmt::arg("totalTime", totalTime), fmt::arg("songPosition", song_pos),
|
fmt::arg("elapsedTime", elapsedTime), fmt::arg("totalTime", totalTime),
|
||||||
fmt::arg("queueLength", queue_length), fmt::arg("stateIcon", stateIcon),
|
fmt::arg("songPosition", song_pos), fmt::arg("queueLength", queue_length),
|
||||||
fmt::arg("consumeIcon", consumeIcon), fmt::arg("randomIcon", randomIcon),
|
fmt::arg("stateIcon", stateIcon), fmt::arg("consumeIcon", consumeIcon),
|
||||||
fmt::arg("repeatIcon", repeatIcon), fmt::arg("singleIcon", singleIcon),
|
fmt::arg("randomIcon", randomIcon), fmt::arg("repeatIcon", repeatIcon),
|
||||||
fmt::arg("filename", filename));
|
fmt::arg("singleIcon", singleIcon), fmt::arg("filename", filename));
|
||||||
if (text.empty()) {
|
if (text.empty()) {
|
||||||
label_.hide();
|
label_.hide();
|
||||||
} else {
|
} else {
|
||||||
@ -198,7 +198,7 @@ void waybar::modules::MPD::setLabel() {
|
|||||||
: "MPD (connected)";
|
: "MPD (connected)";
|
||||||
try {
|
try {
|
||||||
auto tooltip_text =
|
auto tooltip_text =
|
||||||
fmt::format(tooltip_format, fmt::arg("artist", artist.raw()),
|
fmt::format(fmt::runtime(tooltip_format), fmt::arg("artist", artist.raw()),
|
||||||
fmt::arg("albumArtist", album_artist.raw()), fmt::arg("album", album.raw()),
|
fmt::arg("albumArtist", album_artist.raw()), fmt::arg("album", album.raw()),
|
||||||
fmt::arg("title", title.raw()), fmt::arg("date", date),
|
fmt::arg("title", title.raw()), fmt::arg("date", date),
|
||||||
fmt::arg("volume", volume), fmt::arg("elapsedTime", elapsedTime),
|
fmt::arg("volume", volume), fmt::arg("elapsedTime", elapsedTime),
|
||||||
|
@ -378,10 +378,10 @@ auto Mpris::update() -> void {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
auto label_format =
|
auto label_format =
|
||||||
fmt::format(formatstr, fmt::arg("player", info.name), fmt::arg("status", info.status_string),
|
fmt::format(fmt::runtime(formatstr), fmt::arg("player", info.name),
|
||||||
fmt::arg("artist", *info.artist), fmt::arg("title", *info.title),
|
fmt::arg("status", info.status_string), fmt::arg("artist", *info.artist),
|
||||||
fmt::arg("album", *info.album), fmt::arg("length", *info.length),
|
fmt::arg("title", *info.title), fmt::arg("album", *info.album),
|
||||||
fmt::arg("dynamic", dynamic.str()),
|
fmt::arg("length", *info.length), fmt::arg("dynamic", dynamic.str()),
|
||||||
fmt::arg("player_icon", getIcon(config_["player-icons"], info.name)),
|
fmt::arg("player_icon", getIcon(config_["player-icons"], info.name)),
|
||||||
fmt::arg("status_icon", getIcon(config_["status-icons"], info.status_string)));
|
fmt::arg("status_icon", getIcon(config_["status-icons"], info.status_string)));
|
||||||
label_.set_markup(label_format);
|
label_.set_markup(label_format);
|
||||||
|
@ -331,7 +331,7 @@ auto waybar::modules::Network::update() -> void {
|
|||||||
getState(signal_strength_);
|
getState(signal_strength_);
|
||||||
|
|
||||||
auto text = fmt::format(
|
auto text = fmt::format(
|
||||||
format_, fmt::arg("essid", essid_), fmt::arg("signaldBm", signal_strength_dbm_),
|
fmt::runtime(format_), fmt::arg("essid", essid_), fmt::arg("signaldBm", signal_strength_dbm_),
|
||||||
fmt::arg("signalStrength", signal_strength_),
|
fmt::arg("signalStrength", signal_strength_),
|
||||||
fmt::arg("signalStrengthApp", signal_strength_app_), fmt::arg("ifname", ifname_),
|
fmt::arg("signalStrengthApp", signal_strength_app_), fmt::arg("ifname", ifname_),
|
||||||
fmt::arg("netmask", netmask_), fmt::arg("ipaddr", ipaddr_), fmt::arg("gwaddr", gwaddr_),
|
fmt::arg("netmask", netmask_), fmt::arg("ipaddr", ipaddr_), fmt::arg("gwaddr", gwaddr_),
|
||||||
@ -363,8 +363,8 @@ auto waybar::modules::Network::update() -> void {
|
|||||||
}
|
}
|
||||||
if (!tooltip_format.empty()) {
|
if (!tooltip_format.empty()) {
|
||||||
auto tooltip_text = fmt::format(
|
auto tooltip_text = fmt::format(
|
||||||
tooltip_format, fmt::arg("essid", essid_), fmt::arg("signaldBm", signal_strength_dbm_),
|
fmt::runtime(tooltip_format), fmt::arg("essid", essid_),
|
||||||
fmt::arg("signalStrength", signal_strength_),
|
fmt::arg("signaldBm", signal_strength_dbm_), fmt::arg("signalStrength", signal_strength_),
|
||||||
fmt::arg("signalStrengthApp", signal_strength_app_), fmt::arg("ifname", ifname_),
|
fmt::arg("signalStrengthApp", signal_strength_app_), fmt::arg("ifname", ifname_),
|
||||||
fmt::arg("netmask", netmask_), fmt::arg("ipaddr", ipaddr_), fmt::arg("gwaddr", gwaddr_),
|
fmt::arg("netmask", netmask_), fmt::arg("ipaddr", ipaddr_), fmt::arg("gwaddr", gwaddr_),
|
||||||
fmt::arg("cidr", cidr_), fmt::arg("frequency", fmt::format("{:.1f}", frequency_)),
|
fmt::arg("cidr", cidr_), fmt::arg("frequency", fmt::format("{:.1f}", frequency_)),
|
||||||
|
@ -294,9 +294,9 @@ auto waybar::modules::Pulseaudio::update() -> void {
|
|||||||
format_source = config_["format-source"].asString();
|
format_source = config_["format-source"].asString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
format_source = fmt::format(format_source, fmt::arg("volume", source_volume_));
|
format_source = fmt::format(fmt::runtime(format_source), fmt::arg("volume", source_volume_));
|
||||||
auto text = fmt::format(
|
auto text = fmt::format(
|
||||||
format, fmt::arg("desc", desc_), fmt::arg("volume", volume_),
|
fmt::runtime(format), fmt::arg("desc", desc_), fmt::arg("volume", volume_),
|
||||||
fmt::arg("format_source", format_source), fmt::arg("source_volume", source_volume_),
|
fmt::arg("format_source", format_source), fmt::arg("source_volume", source_volume_),
|
||||||
fmt::arg("source_desc", source_desc_), fmt::arg("icon", getIcon(volume_, getPulseIcon())));
|
fmt::arg("source_desc", source_desc_), fmt::arg("icon", getIcon(volume_, getPulseIcon())));
|
||||||
if (text.empty()) {
|
if (text.empty()) {
|
||||||
@ -313,7 +313,7 @@ auto waybar::modules::Pulseaudio::update() -> void {
|
|||||||
}
|
}
|
||||||
if (!tooltip_format.empty()) {
|
if (!tooltip_format.empty()) {
|
||||||
label_.set_tooltip_text(fmt::format(
|
label_.set_tooltip_text(fmt::format(
|
||||||
tooltip_format, fmt::arg("desc", desc_), fmt::arg("volume", volume_),
|
fmt::runtime(tooltip_format), fmt::arg("desc", desc_), fmt::arg("volume", volume_),
|
||||||
fmt::arg("format_source", format_source), fmt::arg("source_volume", source_volume_),
|
fmt::arg("format_source", format_source), fmt::arg("source_volume", source_volume_),
|
||||||
fmt::arg("source_desc", source_desc_),
|
fmt::arg("source_desc", source_desc_),
|
||||||
fmt::arg("icon", getIcon(volume_, getPulseIcon()))));
|
fmt::arg("icon", getIcon(volume_, getPulseIcon()))));
|
||||||
|
@ -103,7 +103,7 @@ void Mode::handle_mode(const char *mode) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
label_.get_style_context()->add_class(mode);
|
label_.get_style_context()->add_class(mode);
|
||||||
label_.set_markup(fmt::format(format_, Glib::Markup::escape_text(mode).raw()));
|
label_.set_markup(fmt::format(fmt::runtime(format_), Glib::Markup::escape_text(mode).raw()));
|
||||||
label_.show();
|
label_.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ void Window::handle_focused_view(const char *title) {
|
|||||||
label_.hide(); // hide empty labels or labels with empty format
|
label_.hide(); // hide empty labels or labels with empty format
|
||||||
} else {
|
} else {
|
||||||
label_.show();
|
label_.show();
|
||||||
label_.set_markup(fmt::format(format_, Glib::Markup::escape_text(title).raw()));
|
label_.set_markup(fmt::format(fmt::runtime(format_), Glib::Markup::escape_text(title).raw()));
|
||||||
}
|
}
|
||||||
|
|
||||||
ALabel::update();
|
ALabel::update();
|
||||||
|
@ -110,7 +110,8 @@ auto Sndio::update() -> void {
|
|||||||
label_.get_style_context()->remove_class("muted");
|
label_.get_style_context()->remove_class("muted");
|
||||||
}
|
}
|
||||||
|
|
||||||
auto text = fmt::format(format, fmt::arg("volume", vol), fmt::arg("raw_value", volume_));
|
auto text =
|
||||||
|
fmt::format(fmt::runtime(format), fmt::arg("volume", vol), fmt::arg("raw_value", volume_));
|
||||||
if (text.empty()) {
|
if (text.empty()) {
|
||||||
label_.hide();
|
label_.hide();
|
||||||
} else {
|
} else {
|
||||||
|
@ -96,14 +96,14 @@ void Language::onEvent(const struct Ipc::ipc_response& res) {
|
|||||||
auto Language::update() -> void {
|
auto Language::update() -> void {
|
||||||
std::lock_guard<std::mutex> lock(mutex_);
|
std::lock_guard<std::mutex> lock(mutex_);
|
||||||
auto display_layout = trim(fmt::format(
|
auto display_layout = trim(fmt::format(
|
||||||
format_, fmt::arg("short", layout_.short_name),
|
fmt::runtime(format_), fmt::arg("short", layout_.short_name),
|
||||||
fmt::arg("shortDescription", layout_.short_description), fmt::arg("long", layout_.full_name),
|
fmt::arg("shortDescription", layout_.short_description), fmt::arg("long", layout_.full_name),
|
||||||
fmt::arg("variant", layout_.variant), fmt::arg("flag", layout_.country_flag())));
|
fmt::arg("variant", layout_.variant), fmt::arg("flag", layout_.country_flag())));
|
||||||
label_.set_markup(display_layout);
|
label_.set_markup(display_layout);
|
||||||
if (tooltipEnabled()) {
|
if (tooltipEnabled()) {
|
||||||
if (tooltip_format_ != "") {
|
if (tooltip_format_ != "") {
|
||||||
auto tooltip_display_layout = trim(
|
auto tooltip_display_layout = trim(
|
||||||
fmt::format(tooltip_format_, fmt::arg("short", layout_.short_name),
|
fmt::format(fmt::runtime(tooltip_format_), fmt::arg("short", layout_.short_name),
|
||||||
fmt::arg("shortDescription", layout_.short_description),
|
fmt::arg("shortDescription", layout_.short_description),
|
||||||
fmt::arg("long", layout_.full_name), fmt::arg("variant", layout_.variant),
|
fmt::arg("long", layout_.full_name), fmt::arg("variant", layout_.variant),
|
||||||
fmt::arg("flag", layout_.country_flag())));
|
fmt::arg("flag", layout_.country_flag())));
|
||||||
|
@ -42,7 +42,7 @@ auto Mode::update() -> void {
|
|||||||
if (mode_.empty()) {
|
if (mode_.empty()) {
|
||||||
event_box_.hide();
|
event_box_.hide();
|
||||||
} else {
|
} else {
|
||||||
label_.set_markup(fmt::format(format_, mode_));
|
label_.set_markup(fmt::format(fmt::runtime(format_), mode_));
|
||||||
if (tooltipEnabled()) {
|
if (tooltipEnabled()) {
|
||||||
label_.set_tooltip_text(mode_);
|
label_.set_tooltip_text(mode_);
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,8 @@ auto Scratchpad::update() -> void {
|
|||||||
if (count_ || show_empty_) {
|
if (count_ || show_empty_) {
|
||||||
event_box_.show();
|
event_box_.show();
|
||||||
label_.set_markup(
|
label_.set_markup(
|
||||||
fmt::format(format_, fmt::arg("icon", getIcon(count_, "", config_["format-icons"].size())),
|
fmt::format(fmt::runtime(format_),
|
||||||
|
fmt::arg("icon", getIcon(count_, "", config_["format-icons"].size())),
|
||||||
fmt::arg("count", count_)));
|
fmt::arg("count", count_)));
|
||||||
if (tooltip_enabled_) {
|
if (tooltip_enabled_) {
|
||||||
label_.set_tooltip_markup(tooltip_text_);
|
label_.set_tooltip_markup(tooltip_text_);
|
||||||
@ -64,7 +65,7 @@ auto Scratchpad::onCmd(const struct Ipc::ipc_response& res) -> void {
|
|||||||
if (tooltip_enabled_) {
|
if (tooltip_enabled_) {
|
||||||
tooltip_text_.clear();
|
tooltip_text_.clear();
|
||||||
for (const auto& window : tree["nodes"][0]["nodes"][0]["floating_nodes"]) {
|
for (const auto& window : tree["nodes"][0]["nodes"][0]["floating_nodes"]) {
|
||||||
tooltip_text_.append(fmt::format(tooltip_format_ + '\n',
|
tooltip_text_.append(fmt::format(fmt::runtime(tooltip_format_ + '\n'),
|
||||||
fmt::arg("app", window["app_id"].asString()),
|
fmt::arg("app", window["app_id"].asString()),
|
||||||
fmt::arg("title", window["name"].asString())));
|
fmt::arg("title", window["name"].asString())));
|
||||||
}
|
}
|
||||||
|
@ -204,9 +204,10 @@ auto Window::update() -> void {
|
|||||||
old_app_id_ = app_id_;
|
old_app_id_ = app_id_;
|
||||||
}
|
}
|
||||||
|
|
||||||
label_.set_markup(fmt::format(
|
label_.set_markup(
|
||||||
format_, fmt::arg("title", waybar::util::rewriteTitle(window_, config_["rewrite"])),
|
fmt::format(fmt::runtime(format_),
|
||||||
fmt::arg("app_id", app_id_), fmt::arg("shell", shell_)));
|
fmt::arg("title", waybar::util::rewriteTitle(window_, config_["rewrite"])),
|
||||||
|
fmt::arg("app_id", app_id_), fmt::arg("shell", shell_)));
|
||||||
if (tooltipEnabled()) {
|
if (tooltipEnabled()) {
|
||||||
label_.set_tooltip_text(window_);
|
label_.set_tooltip_text(window_);
|
||||||
}
|
}
|
||||||
|
@ -233,7 +233,7 @@ auto Workspaces::update() -> void {
|
|||||||
std::string output = (*it)["name"].asString();
|
std::string output = (*it)["name"].asString();
|
||||||
if (config_["format"].isString()) {
|
if (config_["format"].isString()) {
|
||||||
auto format = config_["format"].asString();
|
auto format = config_["format"].asString();
|
||||||
output = fmt::format(format, fmt::arg("icon", getIcon(output, *it)),
|
output = fmt::format(fmt::runtime(format), fmt::arg("icon", getIcon(output, *it)),
|
||||||
fmt::arg("value", output), fmt::arg("name", trimWorkspaceName(output)),
|
fmt::arg("value", output), fmt::arg("name", trimWorkspaceName(output)),
|
||||||
fmt::arg("index", (*it)["num"].asString()));
|
fmt::arg("index", (*it)["num"].asString()));
|
||||||
}
|
}
|
||||||
@ -259,11 +259,9 @@ Gtk::Button &Workspaces::addButton(const Json::Value &node) {
|
|||||||
try {
|
try {
|
||||||
if (node["target_output"].isString()) {
|
if (node["target_output"].isString()) {
|
||||||
ipc_.sendCmd(IPC_COMMAND,
|
ipc_.sendCmd(IPC_COMMAND,
|
||||||
fmt::format(workspace_switch_cmd_ + "; move workspace to output \"{}\"; " +
|
fmt::format(persistent_workspace_switch_cmd_, "--no-auto-back-and-forth",
|
||||||
workspace_switch_cmd_,
|
node["name"].asString(), node["target_output"].asString(),
|
||||||
"--no-auto-back-and-forth", node["name"].asString(),
|
"--no-auto-back-and-forth", node["name"].asString()));
|
||||||
node["target_output"].asString(), "--no-auto-back-and-forth",
|
|
||||||
node["name"].asString()));
|
|
||||||
} else {
|
} else {
|
||||||
ipc_.sendCmd(IPC_COMMAND, fmt::format("workspace {} \"{}\"",
|
ipc_.sendCmd(IPC_COMMAND, fmt::format("workspace {} \"{}\"",
|
||||||
config_["disable-auto-back-and-forth"].asBool()
|
config_["disable-auto-back-and-forth"].asBool()
|
||||||
|
@ -55,7 +55,7 @@ auto waybar::modules::Temperature::update() -> void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto max_temp = config_["critical-threshold"].isInt() ? config_["critical-threshold"].asInt() : 0;
|
auto max_temp = config_["critical-threshold"].isInt() ? config_["critical-threshold"].asInt() : 0;
|
||||||
label_.set_markup(fmt::format(format, fmt::arg("temperatureC", temperature_c),
|
label_.set_markup(fmt::format(fmt::runtime(format), fmt::arg("temperatureC", temperature_c),
|
||||||
fmt::arg("temperatureF", temperature_f),
|
fmt::arg("temperatureF", temperature_f),
|
||||||
fmt::arg("temperatureK", temperature_k),
|
fmt::arg("temperatureK", temperature_k),
|
||||||
fmt::arg("icon", getIcon(temperature_c, "", max_temp))));
|
fmt::arg("icon", getIcon(temperature_c, "", max_temp))));
|
||||||
@ -64,9 +64,9 @@ auto waybar::modules::Temperature::update() -> void {
|
|||||||
if (config_["tooltip-format"].isString()) {
|
if (config_["tooltip-format"].isString()) {
|
||||||
tooltip_format = config_["tooltip-format"].asString();
|
tooltip_format = config_["tooltip-format"].asString();
|
||||||
}
|
}
|
||||||
label_.set_tooltip_text(fmt::format(tooltip_format, fmt::arg("temperatureC", temperature_c),
|
label_.set_tooltip_text(fmt::format(
|
||||||
fmt::arg("temperatureF", temperature_f),
|
fmt::runtime(tooltip_format), fmt::arg("temperatureC", temperature_c),
|
||||||
fmt::arg("temperatureK", temperature_k)));
|
fmt::arg("temperatureF", temperature_f), fmt::arg("temperatureK", temperature_k)));
|
||||||
}
|
}
|
||||||
// Call parent update
|
// Call parent update
|
||||||
ALabel::update();
|
ALabel::update();
|
||||||
|
@ -336,8 +336,8 @@ auto UPower::update() -> void {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
std::string label_format =
|
std::string label_format =
|
||||||
fmt::format(showAltText ? format_alt : format, fmt::arg("percentage", percentString),
|
fmt::format(fmt::runtime(showAltText ? format_alt : format),
|
||||||
fmt::arg("time", time_format));
|
fmt::arg("percentage", percentString), fmt::arg("time", time_format));
|
||||||
// Only set the label text if it doesn't only contain spaces
|
// Only set the label text if it doesn't only contain spaces
|
||||||
bool onlySpaces = true;
|
bool onlySpaces = true;
|
||||||
for (auto& character : label_format) {
|
for (auto& character : label_format) {
|
||||||
|
@ -127,16 +127,16 @@ auto User::update() -> void {
|
|||||||
auto startSystemTime = currentSystemTime - workSystemTimeSeconds;
|
auto startSystemTime = currentSystemTime - workSystemTimeSeconds;
|
||||||
long workSystemDays = uptimeSeconds / 86400;
|
long workSystemDays = uptimeSeconds / 86400;
|
||||||
|
|
||||||
auto label = fmt::format(ALabel::format_, fmt::arg("up_H", fmt::format("{:%H}", startSystemTime)),
|
auto label = fmt::format(
|
||||||
fmt::arg("up_M", fmt::format("{:%M}", startSystemTime)),
|
fmt::runtime(ALabel::format_), fmt::arg("up_H", fmt::format("{:%H}", startSystemTime)),
|
||||||
fmt::arg("up_d", fmt::format("{:%d}", startSystemTime)),
|
fmt::arg("up_M", fmt::format("{:%M}", startSystemTime)),
|
||||||
fmt::arg("up_m", fmt::format("{:%m}", startSystemTime)),
|
fmt::arg("up_d", fmt::format("{:%d}", startSystemTime)),
|
||||||
fmt::arg("up_Y", fmt::format("{:%Y}", startSystemTime)),
|
fmt::arg("up_m", fmt::format("{:%m}", startSystemTime)),
|
||||||
fmt::arg("work_d", workSystemDays),
|
fmt::arg("up_Y", fmt::format("{:%Y}", startSystemTime)), fmt::arg("work_d", workSystemDays),
|
||||||
fmt::arg("work_H", fmt::format("{:%H}", workSystemTimeSeconds)),
|
fmt::arg("work_H", fmt::format("{:%H}", workSystemTimeSeconds)),
|
||||||
fmt::arg("work_M", fmt::format("{:%M}", workSystemTimeSeconds)),
|
fmt::arg("work_M", fmt::format("{:%M}", workSystemTimeSeconds)),
|
||||||
fmt::arg("work_S", fmt::format("{:%S}", workSystemTimeSeconds)),
|
fmt::arg("work_S", fmt::format("{:%S}", workSystemTimeSeconds)),
|
||||||
fmt::arg("user", systemUser));
|
fmt::arg("user", systemUser));
|
||||||
ALabel::label_.set_markup(label);
|
ALabel::label_.set_markup(label);
|
||||||
AIconLabel::update();
|
AIconLabel::update();
|
||||||
}
|
}
|
||||||
|
@ -279,7 +279,7 @@ auto waybar::modules::Wireplumber::update() -> void {
|
|||||||
label_.get_style_context()->remove_class("muted");
|
label_.get_style_context()->remove_class("muted");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string markup = fmt::format(format, fmt::arg("node_name", node_name_),
|
std::string markup = fmt::format(fmt::runtime(format), fmt::arg("node_name", node_name_),
|
||||||
fmt::arg("volume", volume_), fmt::arg("icon", getIcon(volume_)));
|
fmt::arg("volume", volume_), fmt::arg("icon", getIcon(volume_)));
|
||||||
label_.set_markup(markup);
|
label_.set_markup(markup);
|
||||||
|
|
||||||
@ -291,9 +291,9 @@ auto waybar::modules::Wireplumber::update() -> void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!tooltip_format.empty()) {
|
if (!tooltip_format.empty()) {
|
||||||
label_.set_tooltip_text(fmt::format(tooltip_format, fmt::arg("node_name", node_name_),
|
label_.set_tooltip_text(
|
||||||
fmt::arg("volume", volume_),
|
fmt::format(fmt::runtime(tooltip_format), fmt::arg("node_name", node_name_),
|
||||||
fmt::arg("icon", getIcon(volume_))));
|
fmt::arg("volume", volume_), fmt::arg("icon", getIcon(volume_))));
|
||||||
} else {
|
} else {
|
||||||
label_.set_tooltip_text(node_name_);
|
label_.set_tooltip_text(node_name_);
|
||||||
}
|
}
|
||||||
|
@ -618,9 +618,10 @@ void Task::update() {
|
|||||||
app_id = Glib::Markup::escape_text(app_id);
|
app_id = Glib::Markup::escape_text(app_id);
|
||||||
}
|
}
|
||||||
if (!format_before_.empty()) {
|
if (!format_before_.empty()) {
|
||||||
auto txt = fmt::format(format_before_, fmt::arg("title", title), fmt::arg("name", name),
|
auto txt =
|
||||||
fmt::arg("app_id", app_id), fmt::arg("state", state_string()),
|
fmt::format(fmt::runtime(format_before_), fmt::arg("title", title), fmt::arg("name", name),
|
||||||
fmt::arg("short_state", state_string(true)));
|
fmt::arg("app_id", app_id), fmt::arg("state", state_string()),
|
||||||
|
fmt::arg("short_state", state_string(true)));
|
||||||
if (markup)
|
if (markup)
|
||||||
text_before_.set_markup(txt);
|
text_before_.set_markup(txt);
|
||||||
else
|
else
|
||||||
@ -628,9 +629,10 @@ void Task::update() {
|
|||||||
text_before_.show();
|
text_before_.show();
|
||||||
}
|
}
|
||||||
if (!format_after_.empty()) {
|
if (!format_after_.empty()) {
|
||||||
auto txt = fmt::format(format_after_, fmt::arg("title", title), fmt::arg("name", name),
|
auto txt =
|
||||||
fmt::arg("app_id", app_id), fmt::arg("state", state_string()),
|
fmt::format(fmt::runtime(format_after_), fmt::arg("title", title), fmt::arg("name", name),
|
||||||
fmt::arg("short_state", state_string(true)));
|
fmt::arg("app_id", app_id), fmt::arg("state", state_string()),
|
||||||
|
fmt::arg("short_state", state_string(true)));
|
||||||
if (markup)
|
if (markup)
|
||||||
text_after_.set_markup(txt);
|
text_after_.set_markup(txt);
|
||||||
else
|
else
|
||||||
@ -639,9 +641,10 @@ void Task::update() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!format_tooltip_.empty()) {
|
if (!format_tooltip_.empty()) {
|
||||||
auto txt = fmt::format(format_tooltip_, fmt::arg("title", title), fmt::arg("name", name),
|
auto txt =
|
||||||
fmt::arg("app_id", app_id), fmt::arg("state", state_string()),
|
fmt::format(fmt::runtime(format_tooltip_), fmt::arg("title", title), fmt::arg("name", name),
|
||||||
fmt::arg("short_state", state_string(true)));
|
fmt::arg("app_id", app_id), fmt::arg("state", state_string()),
|
||||||
|
fmt::arg("short_state", state_string(true)));
|
||||||
if (markup)
|
if (markup)
|
||||||
button_.set_tooltip_markup(txt);
|
button_.set_tooltip_markup(txt);
|
||||||
else
|
else
|
||||||
|
@ -379,7 +379,7 @@ Workspace::~Workspace() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto Workspace::update() -> void {
|
auto Workspace::update() -> void {
|
||||||
label_.set_markup(fmt::format(format_, fmt::arg("name", name_),
|
label_.set_markup(fmt::format(fmt::runtime(format_), fmt::arg("name", name_),
|
||||||
fmt::arg("icon", with_icon_ ? get_icon() : "")));
|
fmt::arg("icon", with_icon_ ? get_icon() : "")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user