mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
feat(Workspaces): urgent, visible, focused icons
This commit is contained in:
parent
28c65c64e6
commit
7020af7653
@ -18,7 +18,7 @@ class Workspaces : public IModule {
|
|||||||
private:
|
private:
|
||||||
void worker();
|
void worker();
|
||||||
void addWorkspace(Json::Value);
|
void addWorkspace(Json::Value);
|
||||||
std::string getIcon(std::string);
|
std::string getIcon(std::string, Json::Value);
|
||||||
bool handleScroll(GdkEventScroll*);
|
bool handleScroll(GdkEventScroll*);
|
||||||
int getPrevWorkspace();
|
int getPrevWorkspace();
|
||||||
int getNextWorkspace();
|
int getNextWorkspace();
|
||||||
|
@ -8,17 +8,20 @@
|
|||||||
"modules-center": ["sway/window"],
|
"modules-center": ["sway/window"],
|
||||||
"modules-right": ["pulseaudio", "network", "cpu", "memory", "battery", "clock"],
|
"modules-right": ["pulseaudio", "network", "cpu", "memory", "battery", "clock"],
|
||||||
// Modules configuration
|
// Modules configuration
|
||||||
"sway/workspaces": {
|
// "sway/workspaces": {
|
||||||
// "disable-scroll": true,
|
// "disable-scroll": true,
|
||||||
// "all-outputs": true,
|
// "all-outputs": true,
|
||||||
// "format-icons": {
|
// "format-icons": {
|
||||||
// "1": "",
|
// "1": "",
|
||||||
// "2": "",
|
// "2": "",
|
||||||
// "3": "",
|
// "3": "",
|
||||||
// "4": "",
|
// "4": "",
|
||||||
// "5": ""
|
// "5": "",
|
||||||
// }
|
// "urgent": "",
|
||||||
},
|
// "focused": "",
|
||||||
|
// "default": ""
|
||||||
|
// }
|
||||||
|
// },
|
||||||
"sway/window": {
|
"sway/window": {
|
||||||
"max-length": 50
|
"max-length": 50
|
||||||
},
|
},
|
||||||
|
@ -78,6 +78,8 @@ auto waybar::modules::sway::Workspaces::update() -> void
|
|||||||
if (needReorder) {
|
if (needReorder) {
|
||||||
box_.reorder_child(button, node["num"].asInt());
|
box_.reorder_child(button, node["num"].asInt());
|
||||||
}
|
}
|
||||||
|
auto icon = getIcon(node["name"].asString(), node);
|
||||||
|
button.set_label(icon);
|
||||||
button.show();
|
button.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -88,7 +90,7 @@ auto waybar::modules::sway::Workspaces::update() -> void
|
|||||||
|
|
||||||
void waybar::modules::sway::Workspaces::addWorkspace(Json::Value node)
|
void waybar::modules::sway::Workspaces::addWorkspace(Json::Value node)
|
||||||
{
|
{
|
||||||
auto icon = getIcon(node["name"].asString());
|
auto icon = getIcon(node["name"].asString(), node);
|
||||||
auto pair = buttons_.emplace(node["num"].asInt(), icon);
|
auto pair = buttons_.emplace(node["num"].asInt(), icon);
|
||||||
auto &button = pair.first->second;
|
auto &button = pair.first->second;
|
||||||
if (icon != node["name"].asString()) {
|
if (icon != node["name"].asString()) {
|
||||||
@ -123,13 +125,19 @@ void waybar::modules::sway::Workspaces::addWorkspace(Json::Value node)
|
|||||||
button.show();
|
button.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string waybar::modules::sway::Workspaces::getIcon(std::string name)
|
std::string waybar::modules::sway::Workspaces::getIcon(std::string name,
|
||||||
|
Json::Value node)
|
||||||
{
|
{
|
||||||
if (config_["format-icons"][name]) {
|
std::vector<std::string> keys = {
|
||||||
return config_["format-icons"][name].asString();
|
name, "urgent", "focused", "visible", "default"};
|
||||||
}
|
for (auto const& key : keys) {
|
||||||
if (config_["format-icons"]["default"]) {
|
if (key == "focused" || key == "visible" || key == "urgent") {
|
||||||
return config_["format-icons"]["default"].asString();
|
if (config_["format-icons"][key] && node[key].asBool()) {
|
||||||
|
return config_["format-icons"][key].asString();
|
||||||
|
}
|
||||||
|
} else if (config_["format-icons"][key]) {
|
||||||
|
return config_["format-icons"][key].asString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user