fix: use pango markup for consistent formatting in format and tooltip-format
This commit is contained in:
@ -58,11 +58,11 @@ auto waybar::modules::Backlight::update() -> void {
|
|||||||
tooltip_format = config_["tooltip-format"].asString();
|
tooltip_format = config_["tooltip-format"].asString();
|
||||||
}
|
}
|
||||||
if (!tooltip_format.empty()) {
|
if (!tooltip_format.empty()) {
|
||||||
label_.set_tooltip_text(fmt::format(fmt::runtime(tooltip_format),
|
label_.set_tooltip_markup(fmt::format(fmt::runtime(tooltip_format),
|
||||||
fmt::arg("percent", percent),
|
fmt::arg("percent", percent),
|
||||||
fmt::arg("icon", getIcon(percent))));
|
fmt::arg("icon", getIcon(percent))));
|
||||||
} else {
|
} else {
|
||||||
label_.set_tooltip_text(desc);
|
label_.set_tooltip_markup(desc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -27,7 +27,7 @@ auto waybar::modules::Cpu::update() -> void {
|
|||||||
auto [cpu_usage, tooltip] = CpuUsage::getCpuUsage(prev_times_);
|
auto [cpu_usage, tooltip] = CpuUsage::getCpuUsage(prev_times_);
|
||||||
auto [max_frequency, min_frequency, avg_frequency] = CpuFrequency::getCpuFrequency();
|
auto [max_frequency, min_frequency, avg_frequency] = CpuFrequency::getCpuFrequency();
|
||||||
if (tooltipEnabled()) {
|
if (tooltipEnabled()) {
|
||||||
label_.set_tooltip_text(tooltip);
|
label_.set_tooltip_markup(tooltip);
|
||||||
}
|
}
|
||||||
auto format = format_;
|
auto format = format_;
|
||||||
auto total_usage = cpu_usage.empty() ? 0 : cpu_usage[0];
|
auto total_usage = cpu_usage.empty() ? 0 : cpu_usage[0];
|
||||||
|
|||||||
@ -24,7 +24,7 @@ auto waybar::modules::CpuFrequency::update() -> void {
|
|||||||
auto tooltip =
|
auto tooltip =
|
||||||
fmt::format("Minimum frequency: {}\nAverage frequency: {}\nMaximum frequency: {}\n",
|
fmt::format("Minimum frequency: {}\nAverage frequency: {}\nMaximum frequency: {}\n",
|
||||||
min_frequency, avg_frequency, max_frequency);
|
min_frequency, avg_frequency, max_frequency);
|
||||||
label_.set_tooltip_text(tooltip);
|
label_.set_tooltip_markup(tooltip);
|
||||||
}
|
}
|
||||||
auto format = format_;
|
auto format = format_;
|
||||||
auto state = getState(avg_frequency);
|
auto state = getState(avg_frequency);
|
||||||
|
|||||||
@ -21,7 +21,7 @@ auto waybar::modules::CpuUsage::update() -> void {
|
|||||||
// TODO: as creating dynamic fmt::arg arrays is buggy we have to calc both
|
// TODO: as creating dynamic fmt::arg arrays is buggy we have to calc both
|
||||||
auto [cpu_usage, tooltip] = CpuUsage::getCpuUsage(prev_times_);
|
auto [cpu_usage, tooltip] = CpuUsage::getCpuUsage(prev_times_);
|
||||||
if (tooltipEnabled()) {
|
if (tooltipEnabled()) {
|
||||||
label_.set_tooltip_text(tooltip);
|
label_.set_tooltip_markup(tooltip);
|
||||||
}
|
}
|
||||||
auto format = format_;
|
auto format = format_;
|
||||||
auto total_usage = cpu_usage.empty() ? 0 : cpu_usage[0];
|
auto total_usage = cpu_usage.empty() ? 0 : cpu_usage[0];
|
||||||
|
|||||||
@ -81,7 +81,7 @@ 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(fmt::format(
|
label_.set_tooltip_markup(fmt::format(
|
||||||
fmt::runtime(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("used", used),
|
fmt::arg("percentage_free", stats.f_bavail * 100 / stats.f_blocks), fmt::arg("used", used),
|
||||||
fmt::arg("percentage_used", percentage_used), fmt::arg("total", total),
|
fmt::arg("percentage_used", percentage_used), fmt::arg("total", total),
|
||||||
|
|||||||
@ -116,7 +116,7 @@ void Window::handle_frame() {
|
|||||||
updateAppIconName(appid_, "");
|
updateAppIconName(appid_, "");
|
||||||
updateAppIcon();
|
updateAppIcon();
|
||||||
if (tooltipEnabled()) {
|
if (tooltipEnabled()) {
|
||||||
label_.set_tooltip_text(title_);
|
label_.set_tooltip_markup(title_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -212,7 +212,7 @@ auto Gamemode::update() -> void {
|
|||||||
// Tooltip
|
// Tooltip
|
||||||
if (tooltip) {
|
if (tooltip) {
|
||||||
std::string text = fmt::format(fmt::runtime(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_markup(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Label format
|
// Label format
|
||||||
|
|||||||
@ -60,7 +60,7 @@ auto Submap::update() -> void {
|
|||||||
} else {
|
} else {
|
||||||
label_.set_markup(fmt::format(fmt::runtime(format_), submap_));
|
label_.set_markup(fmt::format(fmt::runtime(format_), submap_));
|
||||||
if (tooltipEnabled()) {
|
if (tooltipEnabled()) {
|
||||||
label_.set_tooltip_text(submap_);
|
label_.set_tooltip_markup(submap_);
|
||||||
}
|
}
|
||||||
event_box_.show();
|
event_box_.show();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -72,13 +72,13 @@ auto Window::update() -> void {
|
|||||||
tooltip_format = config_["tooltip-format"].asString();
|
tooltip_format = config_["tooltip-format"].asString();
|
||||||
}
|
}
|
||||||
if (!tooltip_format.empty()) {
|
if (!tooltip_format.empty()) {
|
||||||
label_.set_tooltip_text(
|
label_.set_tooltip_markup(
|
||||||
fmt::format(fmt::runtime(tooltip_format), fmt::arg("title", windowName),
|
fmt::format(fmt::runtime(tooltip_format), fmt::arg("title", windowName),
|
||||||
fmt::arg("initialTitle", windowData_.initial_title),
|
fmt::arg("initialTitle", windowData_.initial_title),
|
||||||
fmt::arg("class", windowData_.class_name),
|
fmt::arg("class", windowData_.class_name),
|
||||||
fmt::arg("initialClass", windowData_.initial_class_name)));
|
fmt::arg("initialClass", windowData_.initial_class_name)));
|
||||||
} else if (!label_text.empty()) {
|
} else if (!label_text.empty()) {
|
||||||
label_.set_tooltip_text(label_text);
|
label_.set_tooltip_markup(label_text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -58,7 +58,7 @@ auto WindowCount::update() -> void {
|
|||||||
} else if (!format.empty()) {
|
} else if (!format.empty()) {
|
||||||
label_.set_markup(fmt::format(fmt::runtime(format), workspace_.windows));
|
label_.set_markup(fmt::format(fmt::runtime(format), workspace_.windows));
|
||||||
} else {
|
} else {
|
||||||
label_.set_text(fmt::format("{}", workspace_.windows));
|
label_.set_markup(fmt::format("{}", workspace_.windows));
|
||||||
}
|
}
|
||||||
|
|
||||||
label_.show();
|
label_.show();
|
||||||
|
|||||||
@ -300,7 +300,7 @@ void Workspace::updateTaskbar(const std::string& workspace_icon) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto window_box = Gtk::make_managed<Gtk::Box>(Gtk::ORIENTATION_HORIZONTAL);
|
auto window_box = Gtk::make_managed<Gtk::Box>(Gtk::ORIENTATION_HORIZONTAL);
|
||||||
window_box->set_tooltip_text(window_repr.window_title);
|
window_box->set_tooltip_markup(window_repr.window_title);
|
||||||
window_box->get_style_context()->add_class("taskbar-window");
|
window_box->get_style_context()->add_class("taskbar-window");
|
||||||
if (window_repr.isActive) {
|
if (window_repr.isActive) {
|
||||||
window_box->get_style_context()->add_class("active");
|
window_box->get_style_context()->add_class("active");
|
||||||
|
|||||||
@ -123,7 +123,7 @@ auto Inhibitor::update() -> void {
|
|||||||
label_.get_style_context()->add_class(status_text);
|
label_.get_style_context()->add_class(status_text);
|
||||||
|
|
||||||
if (tooltipEnabled()) {
|
if (tooltipEnabled()) {
|
||||||
label_.set_tooltip_text(status_text);
|
label_.set_tooltip_markup(status_text);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ALabel::update();
|
return ALabel::update();
|
||||||
|
|||||||
@ -80,7 +80,7 @@ auto JACK::update() -> void {
|
|||||||
if (tooltipEnabled()) {
|
if (tooltipEnabled()) {
|
||||||
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_markup(fmt::format(
|
||||||
fmt::runtime(tooltip_format), fmt::arg("load", std::round(load_)),
|
fmt::runtime(tooltip_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("xruns", xruns_)));
|
fmt::arg("latency", fmt::format("{:.2f}", latency)), fmt::arg("xruns", xruns_)));
|
||||||
|
|||||||
@ -22,7 +22,7 @@ auto waybar::modules::Load::update() -> void {
|
|||||||
auto [load1, load5, load15] = Load::getLoad();
|
auto [load1, load5, load15] = Load::getLoad();
|
||||||
if (tooltipEnabled()) {
|
if (tooltipEnabled()) {
|
||||||
auto tooltip = fmt::format("Load 1: {}\nLoad 5: {}\nLoad 15: {}", load1, load5, load15);
|
auto tooltip = fmt::format("Load 1: {}\nLoad 5: {}\nLoad 15: {}", load1, load5, load15);
|
||||||
label_.set_tooltip_text(tooltip);
|
label_.set_tooltip_markup(tooltip);
|
||||||
}
|
}
|
||||||
auto format = format_;
|
auto format = format_;
|
||||||
auto state = getState(load1);
|
auto state = getState(load1);
|
||||||
|
|||||||
@ -69,7 +69,7 @@ auto waybar::modules::Memory::update() -> void {
|
|||||||
if (tooltipEnabled()) {
|
if (tooltipEnabled()) {
|
||||||
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_markup(fmt::format(
|
||||||
fmt::runtime(tooltip_format), used_ram_percentage,
|
fmt::runtime(tooltip_format), used_ram_percentage,
|
||||||
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),
|
||||||
@ -78,7 +78,7 @@ auto waybar::modules::Memory::update() -> void {
|
|||||||
fmt::arg("swapUsed", used_swap_gigabytes), fmt::arg("avail", available_ram_gigabytes),
|
fmt::arg("swapUsed", used_swap_gigabytes), fmt::arg("avail", available_ram_gigabytes),
|
||||||
fmt::arg("swapAvail", available_swap_gigabytes)));
|
fmt::arg("swapAvail", available_swap_gigabytes)));
|
||||||
} else {
|
} else {
|
||||||
label_.set_tooltip_text(fmt::format("{:.{}f}GiB used", used_ram_gigabytes, 1));
|
label_.set_tooltip_markup(fmt::format("{:.{}f}GiB used", used_ram_gigabytes, 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -110,7 +110,7 @@ void waybar::modules::MPD::setLabel() {
|
|||||||
? config_["tooltip-format-disconnected"].asString()
|
? config_["tooltip-format-disconnected"].asString()
|
||||||
: "MPD (disconnected)";
|
: "MPD (disconnected)";
|
||||||
// Nothing to format
|
// Nothing to format
|
||||||
label_.set_tooltip_text(tooltip_format);
|
label_.set_tooltip_markup(tooltip_format);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -210,7 +210,7 @@ void waybar::modules::MPD::setLabel() {
|
|||||||
fmt::arg("stateIcon", stateIcon), fmt::arg("consumeIcon", consumeIcon),
|
fmt::arg("stateIcon", stateIcon), fmt::arg("consumeIcon", consumeIcon),
|
||||||
fmt::arg("randomIcon", randomIcon), fmt::arg("repeatIcon", repeatIcon),
|
fmt::arg("randomIcon", randomIcon), fmt::arg("repeatIcon", repeatIcon),
|
||||||
fmt::arg("singleIcon", singleIcon), fmt::arg("filename", filename), fmt::arg("uri", uri));
|
fmt::arg("singleIcon", singleIcon), fmt::arg("filename", filename), fmt::arg("uri", uri));
|
||||||
label_.set_tooltip_text(tooltip_text);
|
label_.set_tooltip_markup(tooltip_text);
|
||||||
} catch (fmt::format_error const& e) {
|
} catch (fmt::format_error const& e) {
|
||||||
spdlog::warn("mpd: format error (tooltip): {}", e.what());
|
spdlog::warn("mpd: format error (tooltip): {}", e.what());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -734,7 +734,7 @@ auto Mpris::update() -> void {
|
|||||||
fmt::arg("player_icon", getIconFromJson(config_["player-icons"], info.name)),
|
fmt::arg("player_icon", getIconFromJson(config_["player-icons"], info.name)),
|
||||||
fmt::arg("status_icon", getIconFromJson(config_["status-icons"], info.status_string)));
|
fmt::arg("status_icon", getIconFromJson(config_["status-icons"], info.status_string)));
|
||||||
|
|
||||||
label_.set_tooltip_text(tooltip_text);
|
label_.set_tooltip_markup(tooltip_text);
|
||||||
} catch (fmt::format_error const& e) {
|
} catch (fmt::format_error const& e) {
|
||||||
spdlog::warn("mpris: format error (tooltip): {}", e.what());
|
spdlog::warn("mpris: format error (tooltip): {}", e.what());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -67,7 +67,7 @@ void Window::doUpdate() {
|
|||||||
|
|
||||||
updateAppIconName(appId, "");
|
updateAppIconName(appId, "");
|
||||||
|
|
||||||
if (tooltipEnabled()) label_.set_tooltip_text(title);
|
if (tooltipEnabled()) label_.set_tooltip_markup(title);
|
||||||
|
|
||||||
const auto id = window["id"].asUInt64();
|
const auto id = window["id"].asUInt64();
|
||||||
const auto workspaceId = window["workspace_id"].asUInt64();
|
const auto workspaceId = window["workspace_id"].asUInt64();
|
||||||
|
|||||||
@ -157,7 +157,7 @@ auto PowerProfilesDaemon::update() -> void {
|
|||||||
store.push_back(fmt::arg("icon", getIcon(0, profile.name)));
|
store.push_back(fmt::arg("icon", getIcon(0, profile.name)));
|
||||||
label_.set_markup(fmt::vformat(format_, store));
|
label_.set_markup(fmt::vformat(format_, store));
|
||||||
if (tooltipEnabled()) {
|
if (tooltipEnabled()) {
|
||||||
label_.set_tooltip_text(fmt::vformat(tooltipFormat_, store));
|
label_.set_tooltip_markup(fmt::vformat(tooltipFormat_, store));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set CSS class
|
// Set CSS class
|
||||||
|
|||||||
@ -138,7 +138,7 @@ auto waybar::modules::Pulseaudio::update() -> void {
|
|||||||
fmt::arg("source_volume", source_volume), fmt::arg("source_desc", source_desc),
|
fmt::arg("source_volume", source_volume), fmt::arg("source_desc", source_desc),
|
||||||
fmt::arg("icon", getIcon(sink_volume, getPulseIcon()))));
|
fmt::arg("icon", getIcon(sink_volume, getPulseIcon()))));
|
||||||
} else {
|
} else {
|
||||||
label_.set_tooltip_text(sink_desc);
|
label_.set_tooltip_markup(sink_desc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -25,9 +25,9 @@ auto waybar::modules::Clock::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();
|
||||||
auto tooltip_text = fmt::format(fmt::runtime(tooltip_format), localtime);
|
auto tooltip_text = fmt::format(fmt::runtime(tooltip_format), localtime);
|
||||||
label_.set_tooltip_text(tooltip_text);
|
label_.set_tooltip_markup(tooltip_text);
|
||||||
} else {
|
} else {
|
||||||
label_.set_tooltip_text(text);
|
label_.set_tooltip_markup(text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Call parent update
|
// Call parent update
|
||||||
|
|||||||
@ -44,7 +44,7 @@ auto Mode::update() -> void {
|
|||||||
} else {
|
} else {
|
||||||
label_.set_markup(fmt::format(fmt::runtime(format_), mode_));
|
label_.set_markup(fmt::format(fmt::runtime(format_), mode_));
|
||||||
if (tooltipEnabled()) {
|
if (tooltipEnabled()) {
|
||||||
label_.set_tooltip_text(mode_);
|
label_.set_tooltip_markup(mode_);
|
||||||
}
|
}
|
||||||
event_box_.show();
|
event_box_.show();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -99,7 +99,7 @@ auto Window::update() -> void {
|
|||||||
fmt::arg("shell", shell_), fmt::arg("marks", marks_)),
|
fmt::arg("shell", shell_), fmt::arg("marks", marks_)),
|
||||||
config_["rewrite"]));
|
config_["rewrite"]));
|
||||||
if (tooltipEnabled()) {
|
if (tooltipEnabled()) {
|
||||||
label_.set_tooltip_text(window_);
|
label_.set_tooltip_markup(window_);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateAppIcon();
|
updateAppIcon();
|
||||||
|
|||||||
@ -479,12 +479,12 @@ auto waybar::modules::Wireplumber::update() -> void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!tooltipFormat.empty()) {
|
if (!tooltipFormat.empty()) {
|
||||||
label_.set_tooltip_text(fmt::format(
|
label_.set_tooltip_markup(fmt::format(
|
||||||
fmt::runtime(tooltipFormat), fmt::arg("node_name", node_name_), fmt::arg("volume", vol),
|
fmt::runtime(tooltipFormat), fmt::arg("node_name", node_name_), fmt::arg("volume", vol),
|
||||||
fmt::arg("icon", getIcon(vol)), fmt::arg("format_source", formatted_source),
|
fmt::arg("icon", getIcon(vol)), fmt::arg("format_source", formatted_source),
|
||||||
fmt::arg("source_volume", source_vol), fmt::arg("source_desc", source_name_)));
|
fmt::arg("source_volume", source_vol), fmt::arg("source_desc", source_name_)));
|
||||||
} else {
|
} else {
|
||||||
label_.set_tooltip_text(node_name_);
|
label_.set_tooltip_markup(node_name_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -509,7 +509,7 @@ void Task::update() {
|
|||||||
if (markup)
|
if (markup)
|
||||||
button.set_tooltip_markup(txt);
|
button.set_tooltip_markup(txt);
|
||||||
else
|
else
|
||||||
button.set_tooltip_text(txt);
|
button.set_tooltip_markup(txt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user