mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
feat(Workspaces): format
This commit is contained in:
parent
55e1905284
commit
d914429194
@ -11,6 +11,7 @@
|
||||
// "sway/workspaces": {
|
||||
// "disable-scroll": true,
|
||||
// "all-outputs": true,
|
||||
// "format": "{name}: {icon}",
|
||||
// "format-icons": {
|
||||
// "1": "",
|
||||
// "2": "",
|
||||
|
@ -18,10 +18,6 @@ window {
|
||||
border-bottom: 3px solid transparent;
|
||||
}
|
||||
|
||||
#workspaces button.icon label {
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
#workspaces button.focused {
|
||||
background: #64727D;
|
||||
border-bottom: 3px solid white;
|
||||
|
@ -79,7 +79,13 @@ auto waybar::modules::sway::Workspaces::update() -> void
|
||||
box_.reorder_child(button, node["num"].asInt());
|
||||
}
|
||||
auto icon = getIcon(node["name"].asString(), node);
|
||||
if (config_["format"]) {
|
||||
auto format = config_["format"].asString();
|
||||
button.set_label(fmt::format(format, fmt::arg("icon", icon),
|
||||
fmt::arg("name", node["name"].asString())));
|
||||
} else {
|
||||
button.set_label(icon);
|
||||
}
|
||||
button.show();
|
||||
}
|
||||
}
|
||||
@ -91,11 +97,12 @@ auto waybar::modules::sway::Workspaces::update() -> void
|
||||
void waybar::modules::sway::Workspaces::addWorkspace(Json::Value node)
|
||||
{
|
||||
auto icon = getIcon(node["name"].asString(), node);
|
||||
auto pair = buttons_.emplace(node["num"].asInt(), icon);
|
||||
auto format = config_["format"]
|
||||
? fmt::format(config_["format"].asString(), fmt::arg("icon", icon),
|
||||
fmt::arg("name", node["name"].asString()))
|
||||
: icon;
|
||||
auto pair = buttons_.emplace(node["num"].asInt(), format);
|
||||
auto &button = pair.first->second;
|
||||
if (icon != node["name"].asString()) {
|
||||
button.get_style_context()->add_class("icon");
|
||||
}
|
||||
box_.pack_start(button, false, false, 0);
|
||||
button.set_relief(Gtk::RELIEF_NONE);
|
||||
button.signal_clicked().connect([this, pair] {
|
||||
|
Loading…
Reference in New Issue
Block a user