Add CSS classes for sway workspace indicators depending on associated output
Allows for different styles of workspace indicators (buttons) depending
on the output the workspace is located at.
Using this one can for example color the indicators depending on the
output making it easy to infer on which output a workspace is located.
Example config:
"sway/workspaces": {
"all-outputs": true,
"format": "{name}",
"output-classes": {
"DP-1": "output1",
"LVDS-2": "output2"
}
}
Example CSS:
#workspaces button.output1{
background-color: green;
}
#workspaces button.output2{
background-color: blue;
}
This commit is contained in:
@@ -321,6 +321,17 @@ auto Workspaces::update() -> void {
|
||||
button.get_style_context()->remove_class("empty");
|
||||
}
|
||||
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) {
|
||||
button.get_style_context()->add_class("current_output");
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user