add high-priority-named optiion
This commit is contained in:
parent
430f0e5d65
commit
d3bcff31e5
|
@ -41,6 +41,7 @@ class Workspaces : public AModule, public sigc::trackable {
|
||||||
|
|
||||||
const Bar& bar_;
|
const Bar& bar_;
|
||||||
std::vector<Json::Value> workspaces_;
|
std::vector<Json::Value> workspaces_;
|
||||||
|
std::vector<std::string> high_priority_named_;
|
||||||
std::vector<std::string> workspaces_order_;
|
std::vector<std::string> workspaces_order_;
|
||||||
Gtk::Box box_;
|
Gtk::Box box_;
|
||||||
util::JsonParser parser_;
|
util::JsonParser parser_;
|
||||||
|
|
|
@ -102,6 +102,7 @@ Additional to workspace name matching, the following *format-icons* can be set.
|
||||||
- *urgent*: Will be shown, when workspace is flagged as urgent
|
- *urgent*: Will be shown, when workspace is flagged as urgent
|
||||||
- *focused*: Will be shown, when workspace is focused
|
- *focused*: Will be shown, when workspace is focused
|
||||||
- *persistent*: Will be shown, when workspace is persistent one.
|
- *persistent*: Will be shown, when workspace is persistent one.
|
||||||
|
- *high-priority-named*: Icons by names will be shown always for that workspaces, independent by state.
|
||||||
|
|
||||||
# PERSISTENT WORKSPACES
|
# PERSISTENT WORKSPACES
|
||||||
|
|
||||||
|
@ -134,6 +135,7 @@ n.b.: the list of outputs can be obtained from command line using *swaymsg -t ge
|
||||||
"3": "",
|
"3": "",
|
||||||
"4": "",
|
"4": "",
|
||||||
"5": "",
|
"5": "",
|
||||||
|
"high-priority-named": [ "1", "2" ],
|
||||||
"urgent": "",
|
"urgent": "",
|
||||||
"focused": "",
|
"focused": "",
|
||||||
"default": ""
|
"default": ""
|
||||||
|
|
|
@ -28,6 +28,11 @@ Workspaces::Workspaces(const std::string &id, const Bar &bar, const Json::Value
|
||||||
: AModule(config, "workspaces", id, false, !config["disable-scroll"].asBool()),
|
: AModule(config, "workspaces", id, false, !config["disable-scroll"].asBool()),
|
||||||
bar_(bar),
|
bar_(bar),
|
||||||
box_(bar.vertical ? Gtk::ORIENTATION_VERTICAL : Gtk::ORIENTATION_HORIZONTAL, 0) {
|
box_(bar.vertical ? Gtk::ORIENTATION_VERTICAL : Gtk::ORIENTATION_HORIZONTAL, 0) {
|
||||||
|
if (config["format-icons"]["high-priority-named"].isArray()) {
|
||||||
|
for (auto &it : config["format-icons"]["high-priority-named"]) {
|
||||||
|
high_priority_named_.push_back(it.asString());
|
||||||
|
}
|
||||||
|
}
|
||||||
box_.set_name("workspaces");
|
box_.set_name("workspaces");
|
||||||
if (!id.empty()) {
|
if (!id.empty()) {
|
||||||
box_.get_style_context()->add_class(id);
|
box_.get_style_context()->add_class(id);
|
||||||
|
@ -279,9 +284,22 @@ Gtk::Button &Workspaces::addButton(const Json::Value &node) {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Workspaces::getIcon(const std::string &name, const Json::Value &node) {
|
std::string Workspaces::getIcon(const std::string &name, const Json::Value &node) {
|
||||||
std::vector<std::string> keys = {"urgent", "focused", name, "visible", "default"};
|
std::vector<std::string> keys = {"high-priority-named", "urgent", "focused", name, "default"};
|
||||||
for (auto const &key : keys) {
|
for (auto const &key : keys) {
|
||||||
if (key == "focused" || key == "visible" || key == "urgent") {
|
if (key == "high-priority-named") {
|
||||||
|
auto it = std::find_if(high_priority_named_.begin(), high_priority_named_.end(),
|
||||||
|
[&](const std::string &member) { return member == name; });
|
||||||
|
if (it != high_priority_named_.end()) {
|
||||||
|
return config_["format-icons"][name].asString();
|
||||||
|
}
|
||||||
|
|
||||||
|
it = std::find_if(high_priority_named_.begin(), high_priority_named_.end(),
|
||||||
|
[&](const std::string &member) { return trimWorkspaceName(member) == trimWorkspaceName(name); });
|
||||||
|
if (it != high_priority_named_.end()) {
|
||||||
|
return config_["format-icons"][trimWorkspaceName(name)].asString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (key == "focused" || key == "urgent") {
|
||||||
if (config_["format-icons"][key].isString() && node[key].asBool()) {
|
if (config_["format-icons"][key].isString() && node[key].asBool()) {
|
||||||
return config_["format-icons"][key].asString();
|
return config_["format-icons"][key].asString();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue