From c602d38c8eac402c82cec10c57b0da8283e9a202 Mon Sep 17 00:00:00 2001 From: Michael Rodler Date: Mon, 4 May 2020 16:16:09 +0200 Subject: [PATCH] sway/workspaces added current_output CSS class to buttons. All workspace buttons that are visible on the same output as the current waybar can be styled with the `current_output` css class. This is really only useful in combination with the `"all-outputs": true`. Then the workspaces that are on the current output can be styled differently than the workspace on other outputs, while all are visible in the waybar. --- man/waybar-sway-workspaces.5.scd | 1 + src/modules/sway/workspaces.cpp | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/man/waybar-sway-workspaces.5.scd b/man/waybar-sway-workspaces.5.scd index 18fe6f40..9c9c2142 100644 --- a/man/waybar-sway-workspaces.5.scd +++ b/man/waybar-sway-workspaces.5.scd @@ -128,3 +128,4 @@ n.b.: the list of outputs can be obtained from command line using *swaymsg -t ge - *#workspaces button.focused* - *#workspaces button.urgent* - *#workspaces button.persistent* +- *#workspaces button.current_output* diff --git a/src/modules/sway/workspaces.cpp b/src/modules/sway/workspaces.cpp index 91df1134..bd003cb2 100644 --- a/src/modules/sway/workspaces.cpp +++ b/src/modules/sway/workspaces.cpp @@ -154,6 +154,15 @@ auto Workspaces::update() -> void { } else { button.get_style_context()->remove_class("persistent"); } + if ((*it)["output"].isString()) { + if (((*it)["output"].asString()) == bar_.output->name) { + button.get_style_context()->add_class("current_output"); + } else { + button.get_style_context()->remove_class("current_output"); + } + } else { + button.get_style_context()->remove_class("current_output"); + } if (needReorder) { box_.reorder_child(button, it - workspaces_.begin()); }