From 383949795eb23a15809b39ae79f5c1849e09af87 Mon Sep 17 00:00:00 2001 From: LoricAndre Date: Wed, 23 Jul 2025 17:38:25 +0200 Subject: [PATCH 1/3] feat(hyprland/workspaces): add uniqueIcons option --- include/modules/hyprland/workspaces.hpp | 2 ++ src/modules/hyprland/workspace.cpp | 6 +++++- src/modules/hyprland/workspaces.cpp | 3 ++- test/config.cpp | 1 + test/config/hyprland-workspaces.json | 1 + 5 files changed, 11 insertions(+), 2 deletions(-) diff --git a/include/modules/hyprland/workspaces.hpp b/include/modules/hyprland/workspaces.hpp index 9a44e594..9cc81ec9 100644 --- a/include/modules/hyprland/workspaces.hpp +++ b/include/modules/hyprland/workspaces.hpp @@ -39,6 +39,7 @@ class Workspaces : public AModule, public EventHandler { auto specialVisibleOnly() const -> bool { return m_specialVisibleOnly; } auto persistentOnly() const -> bool { return m_persistentOnly; } auto moveToMonitor() const -> bool { return m_moveToMonitor; } + auto uniqueIcons() const -> bool { return m_uniqueIcons; } auto getBarOutput() const -> std::string { return m_bar.output->name; } @@ -126,6 +127,7 @@ class Workspaces : public AModule, public EventHandler { bool m_specialVisibleOnly = false; bool m_persistentOnly = false; bool m_moveToMonitor = false; + bool m_uniqueIcons = false; Json::Value m_persistentWorkspaceConfig; // Map for windows stored in workspaces not present in the current bar. diff --git a/src/modules/hyprland/workspace.cpp b/src/modules/hyprland/workspace.cpp index b58c1719..01678a54 100644 --- a/src/modules/hyprland/workspace.cpp +++ b/src/modules/hyprland/workspace.cpp @@ -1,6 +1,7 @@ #include #include +#include #include #include #include @@ -95,7 +96,10 @@ void Workspace::insertWindow(WindowCreationPayload create_window_payload) { if (!create_window_payload.isEmpty(m_workspaceManager)) { auto repr = create_window_payload.repr(m_workspaceManager); - if (!repr.empty()) { + if (!repr.empty() && (!m_workspaceManager.uniqueIcons() || + std::ranges::find_if(m_windowMap, [&repr](const auto &x) { + return x.second == repr; + }) == m_windowMap.end())) { m_windowMap[create_window_payload.getAddress()] = repr; } } diff --git a/src/modules/hyprland/workspaces.cpp b/src/modules/hyprland/workspaces.cpp index cfc62025..1c5d6e38 100644 --- a/src/modules/hyprland/workspaces.cpp +++ b/src/modules/hyprland/workspaces.cpp @@ -609,6 +609,7 @@ auto Workspaces::parseConfig(const Json::Value &config) -> void { populateBoolConfig(config, "persistent-only", m_persistentOnly); populateBoolConfig(config, "active-only", m_activeOnly); populateBoolConfig(config, "move-to-monitor", m_moveToMonitor); + populateBoolConfig(config, "unique-icons", m_uniqueIcons); m_persistentWorkspaceConfig = config.get("persistent-workspaces", Json::Value()); populateSortByConfig(config); @@ -1038,4 +1039,4 @@ std::optional Workspaces::parseWorkspaceId(std::string const &workspaceIdSt } } -} // namespace waybar::modules::hyprland \ No newline at end of file +} // namespace waybar::modules::hyprland diff --git a/test/config.cpp b/test/config.cpp index c60519ce..22d0b07e 100644 --- a/test/config.cpp +++ b/test/config.cpp @@ -139,6 +139,7 @@ TEST_CASE("Load Hyprland Workspaces bar config", "[config]") { REQUIRE(hyprland["active-only"].asBool() == true); REQUIRE(hyprland["all-outputs"].asBool() == false); REQUIRE(hyprland["move-to-monitor"].asBool() == true); + REQUIRE(hyprland["unique-icons"].asBool() == true); REQUIRE(hyprland["format"].asString() == "{icon} {windows}"); REQUIRE(hyprland["format-window-separator"].asString() == " "); REQUIRE(hyprland["on-scroll-down"].asString() == "hyprctl dispatch workspace e-1"); diff --git a/test/config/hyprland-workspaces.json b/test/config/hyprland-workspaces.json index dd733897..903e94f9 100644 --- a/test/config/hyprland-workspaces.json +++ b/test/config/hyprland-workspaces.json @@ -29,6 +29,7 @@ "window-rewrite": { "title": "" }, + "unique-icons": true, "window-rewrite-default": "", "window-rewrite-separator": " ", "sort-by": "number" From d1f3c0ef95a0cc9db346642cefbd7ce125e7e953 Mon Sep 17 00:00:00 2001 From: LoricAndre Date: Wed, 23 Jul 2025 17:46:46 +0200 Subject: [PATCH 2/3] docs: update man page --- man/waybar-hyprland-workspaces.5.scd | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/man/waybar-hyprland-workspaces.5.scd b/man/waybar-hyprland-workspaces.5.scd index f48d6f78..9119e7de 100644 --- a/man/waybar-hyprland-workspaces.5.scd +++ b/man/waybar-hyprland-workspaces.5.scd @@ -70,6 +70,11 @@ Addressed by *hyprland/workspaces* Otherwise, the workspace will open on the monitor where it was previously assigned. Analog to using `focusworkspaceoncurrentmonitor` dispatcher instead of `workspace` in Hyprland. +*unique-icons*: ++ + typeof: bool ++ + default: false ++ + If set to true, only one instance of each window icon will be shown per workspace + *ignore-workspaces*: ++ typeof: array ++ default: [] ++ From af1ccf7d865133aad55ecfc6bab7ed3f14c43f69 Mon Sep 17 00:00:00 2001 From: LoricAndre Date: Wed, 23 Jul 2025 17:48:53 +0200 Subject: [PATCH 3/3] docs: add missing final period --- man/waybar-hyprland-workspaces.5.scd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/waybar-hyprland-workspaces.5.scd b/man/waybar-hyprland-workspaces.5.scd index 9119e7de..61646deb 100644 --- a/man/waybar-hyprland-workspaces.5.scd +++ b/man/waybar-hyprland-workspaces.5.scd @@ -73,7 +73,7 @@ Addressed by *hyprland/workspaces* *unique-icons*: ++ typeof: bool ++ default: false ++ - If set to true, only one instance of each window icon will be shown per workspace + If set to true, only one instance of each window icon will be shown per workspace. *ignore-workspaces*: ++ typeof: array ++