Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions include/modules/hyprland/workspaces.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand Down Expand Up @@ -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.
Expand Down
5 changes: 5 additions & 0 deletions man/waybar-hyprland-workspaces.5.scd
Original file line number Diff line number Diff line change
Expand Up @@ -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: [] ++
Expand Down
6 changes: 5 additions & 1 deletion src/modules/hyprland/workspace.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <json/value.h>
#include <spdlog/spdlog.h>

#include <algorithm>
#include <memory>
#include <string>
#include <utility>
Expand Down Expand Up @@ -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;
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/modules/hyprland/workspaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -1038,4 +1039,4 @@ std::optional<int> Workspaces::parseWorkspaceId(std::string const &workspaceIdSt
}
}

} // namespace waybar::modules::hyprland
} // namespace waybar::modules::hyprland
1 change: 1 addition & 0 deletions test/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
1 change: 1 addition & 0 deletions test/config/hyprland-workspaces.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"window-rewrite": {
"title<Steam>": ""
},
"unique-icons": true,
"window-rewrite-default": "",
"window-rewrite-separator": " ",
"sort-by": "number"
Expand Down