From e93259c7bb5602e8747dca30fd7e0ea25f062023 Mon Sep 17 00:00:00 2001 From: Guilherme Daher <> Date: Tue, 11 Aug 2026 16:37:39 -0300 Subject: [PATCH 1/2] feat: active-by option added on hyprland config - allows the choice between show as active by id or name --- include/modules/hyprland/workspaces.hpp | 8 ++++++++ man/waybar-hyprland-workspaces.5.scd | 7 +++++++ src/modules/hyprland/workspaces.cpp | 22 ++++++++++++++++++++-- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/include/modules/hyprland/workspaces.hpp b/include/modules/hyprland/workspaces.hpp index c29ec30ce5..dab17a072e 100644 --- a/include/modules/hyprland/workspaces.hpp +++ b/include/modules/hyprland/workspaces.hpp @@ -92,6 +92,7 @@ class Workspaces : public AModule, public EventHandler { static auto populateBoolConfig(const Json::Value& config, const std::string& key, bool& member) -> void; auto populateSortByConfig(const Json::Value& config) -> void; + auto populateActiveByConfig(const Json::Value& config) -> void; auto populateIgnoreWorkspacesConfig(const Json::Value& config) -> void; auto populateFormatWindowSeparatorConfig(const Json::Value& config) -> void; auto populateWindowRewriteConfig(const Json::Value& config) -> void; @@ -173,6 +174,13 @@ class Workspaces : public AModule, public EventHandler { {"NUMBER", SortMethod::NUMBER}, {"SPECIAL-CENTERED", SortMethod::SPECIAL_CENTERED}, {"DEFAULT", SortMethod::DEFAULT}}; + + enum class ActiveMethod { ID, NAME, DEFAULT }; + ActiveMethod m_activeBy = ActiveMethod::DEFAULT; + static inline const std::map m_activeMap = {{"ID", ActiveMethod::ID}, + {"NAME", ActiveMethod::NAME}, + {"DEFAULT", ActiveMethod::DEFAULT} + }; std::string m_formatBefore; std::string m_formatAfter; diff --git a/man/waybar-hyprland-workspaces.5.scd b/man/waybar-hyprland-workspaces.5.scd index 3010fb4558..1a9b0ef06d 100644 --- a/man/waybar-hyprland-workspaces.5.scd +++ b/man/waybar-hyprland-workspaces.5.scd @@ -147,6 +147,13 @@ This setting is ignored if *workspace-taskbar.enable* is set to true. default: false ++ If set to false workspaces group will be shown only in assigned output. Otherwise, all workspace groups are shown. +*active-by*: ++ + typeof: string ++ + default: "default" ++ + If set to id, workspaces will be set as active by id. + If set to name, workspaces will set as active by name. + If none of those, workspaces will set as active by default behavior. + *active-only*: ++ typeof: bool ++ default: false ++ diff --git a/src/modules/hyprland/workspaces.cpp b/src/modules/hyprland/workspaces.cpp index 780e041d8c..61e2979851 100644 --- a/src/modules/hyprland/workspaces.cpp +++ b/src/modules/hyprland/workspaces.cpp @@ -637,6 +637,7 @@ auto Workspaces::parseConfig(const Json::Value& config) -> void { m_persistentWorkspaceConfig = config.get("persistent-workspaces", Json::Value()); populateSortByConfig(config); + populateActiveByConfig(config); populateIgnoreWorkspacesConfig(config); populateFormatWindowSeparatorConfig(config); @@ -691,6 +692,20 @@ auto Workspaces::populateSortByConfig(const Json::Value& config) -> void { } } +auto Workspaces::populateActiveByConfig(const Json::Value& config) -> void { + const auto& configActiveBy = config["active-by"]; + if (configActiveBy.isString()) { + auto activeByStr = configActiveBy.asString(); + try { + m_activeBy = waybar::util::parseStringToEnum(activeByStr, m_activeMap); + } catch (const std::invalid_argument& e) { + m_activeBy = ActiveMethod::DEFAULT; + spdlog::warn( + "Invalid string representation for active-by. Falling back to default active method."); + } + } +} + auto Workspaces::populateIgnoreWorkspacesConfig(const Json::Value& config) -> void { auto ignoreWorkspaces = config["ignore-workspaces"]; if (ignoreWorkspaces.isArray()) { @@ -1103,10 +1118,13 @@ void Workspaces::updateWorkspaceStates() { for (auto& workspace : m_workspaces) { bool isActiveByName = - !currentWorkspaceName.empty() && workspace->name() == currentWorkspaceName; + !currentWorkspaceName.empty() && + workspace->name() == currentWorkspaceName; workspace->setActive( - workspace->id() == m_activeWorkspaceId || isActiveByName || + ((m_activeBy == ActiveMethod::ID || m_activeBy == ActiveMethod::DEFAULT) && + workspace->id() == m_activeWorkspaceId ) || + (m_activeBy == ActiveMethod::NAME && isActiveByName) || (workspace->isSpecial() && workspace->name() == m_activeSpecialWorkspaceName)); if (workspace->isActive() && workspace->isUrgent()) { workspace->setUrgent(false); From 97bc2c09b3a148a1f5d13986ccd80916053277af Mon Sep 17 00:00:00 2001 From: Guilherme Daher <> Date: Thu, 13 Aug 2026 08:17:56 -0300 Subject: [PATCH 2/2] fix: include/modules/hyprland/workspaces.hpp formatted with clang --- include/modules/hyprland/workspaces.hpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/include/modules/hyprland/workspaces.hpp b/include/modules/hyprland/workspaces.hpp index 7c551488fb..888741efd0 100644 --- a/include/modules/hyprland/workspaces.hpp +++ b/include/modules/hyprland/workspaces.hpp @@ -170,18 +170,17 @@ class Workspaces : public AModule, public EventHandler { enum class SortMethod { ID, NAME, NUMBER, SPECIAL_CENTERED, DEFAULT }; SortMethod m_sortBy = SortMethod::DEFAULT; - static inline const std::map m_sortMap = {{"ID", SortMethod::ID}, - {"NAME", SortMethod::NAME}, - {"NUMBER", SortMethod::NUMBER}, - {"SPECIAL-CENTERED", SortMethod::SPECIAL_CENTERED}, - {"DEFAULT", SortMethod::DEFAULT}}; - + static inline const std::map m_sortMap = { + {"ID", SortMethod::ID}, + {"NAME", SortMethod::NAME}, + {"NUMBER", SortMethod::NUMBER}, + {"SPECIAL-CENTERED", SortMethod::SPECIAL_CENTERED}, + {"DEFAULT", SortMethod::DEFAULT}}; + enum class ActiveMethod { ID, NAME, DEFAULT }; ActiveMethod m_activeBy = ActiveMethod::DEFAULT; - static inline const std::map m_activeMap = {{"ID", ActiveMethod::ID}, - {"NAME", ActiveMethod::NAME}, - {"DEFAULT", ActiveMethod::DEFAULT} - }; + static inline const std::map m_activeMap = { + {"ID", ActiveMethod::ID}, {"NAME", ActiveMethod::NAME}, {"DEFAULT", ActiveMethod::DEFAULT}}; std::string m_formatBefore; std::string m_formatAfter;