Merge pull request #4193 from burbschat/output-classes
Add CSS classes for sway workspace indicators depending on associated output
This commit is contained in:
@@ -115,6 +115,12 @@ warp-on-scroll: ++
|
|||||||
default: false ++
|
default: false ++
|
||||||
Enables this module to consume all left over space dynamically.
|
Enables this module to consume all left over space dynamically.
|
||||||
|
|
||||||
|
*output-classes*: ++
|
||||||
|
typeof: array ++
|
||||||
|
Specify additional CSS classes to be added to workspace indicators based on the output on which the associated workspace is located.
|
||||||
|
Keys are output names and values are class names like *${output}: {output-class}*.
|
||||||
|
Assignment in config is used to keep the stylesheet independent of the available outputs.
|
||||||
|
|
||||||
|
|
||||||
# FORMAT REPLACEMENTS
|
# FORMAT REPLACEMENTS
|
||||||
|
|
||||||
@@ -210,3 +216,4 @@ n.b.: the list of outputs can be obtained from command line using *swaymsg -t ge
|
|||||||
- *#workspaces button.empty*
|
- *#workspaces button.empty*
|
||||||
- *#workspaces button.current_output*
|
- *#workspaces button.current_output*
|
||||||
- *#workspaces button#sway-workspace-${name}*
|
- *#workspaces button#sway-workspace-${name}*
|
||||||
|
- *#workspaces button.${output-class}*
|
||||||
|
|||||||
@@ -357,6 +357,18 @@ auto Workspaces::update() -> void {
|
|||||||
button.get_style_context()->remove_class("empty");
|
button.get_style_context()->remove_class("empty");
|
||||||
}
|
}
|
||||||
if ((*it)["output"].isString()) {
|
if ((*it)["output"].isString()) {
|
||||||
|
// Simply attempt to remove all output classes every time to reset output classes. This works
|
||||||
|
// even if a class has not been previously added to the style context.
|
||||||
|
for (const auto &oclass : config_["output-classes"]) {
|
||||||
|
button.get_style_context()->remove_class(oclass.asString());
|
||||||
|
}
|
||||||
|
// If output-classes contains a class for output associated with current workspace button, add
|
||||||
|
// the class to its style context.
|
||||||
|
std::string output_name = (*it)["output"].asString();
|
||||||
|
if (config_["output-classes"].isMember(output_name) &&
|
||||||
|
config_["output-classes"][output_name].isString()) {
|
||||||
|
button.get_style_context()->add_class(config_["output-classes"][output_name].asString());
|
||||||
|
}
|
||||||
if (((*it)["output"].asString()) == bar_.output->name) {
|
if (((*it)["output"].asString()) == bar_.output->name) {
|
||||||
button.get_style_context()->add_class("current_output");
|
button.get_style_context()->add_class("current_output");
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user