feat(hyprland/workspaces): add uniqueIcons option
This commit is contained in:
@@ -39,6 +39,7 @@ class Workspaces : public AModule, public EventHandler {
|
|||||||
auto specialVisibleOnly() const -> bool { return m_specialVisibleOnly; }
|
auto specialVisibleOnly() const -> bool { return m_specialVisibleOnly; }
|
||||||
auto persistentOnly() const -> bool { return m_persistentOnly; }
|
auto persistentOnly() const -> bool { return m_persistentOnly; }
|
||||||
auto moveToMonitor() const -> bool { return m_moveToMonitor; }
|
auto moveToMonitor() const -> bool { return m_moveToMonitor; }
|
||||||
|
auto uniqueIcons() const -> bool { return m_uniqueIcons; }
|
||||||
|
|
||||||
auto getBarOutput() const -> std::string { return m_bar.output->name; }
|
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_specialVisibleOnly = false;
|
||||||
bool m_persistentOnly = false;
|
bool m_persistentOnly = false;
|
||||||
bool m_moveToMonitor = false;
|
bool m_moveToMonitor = false;
|
||||||
|
bool m_uniqueIcons = false;
|
||||||
Json::Value m_persistentWorkspaceConfig;
|
Json::Value m_persistentWorkspaceConfig;
|
||||||
|
|
||||||
// Map for windows stored in workspaces not present in the current bar.
|
// Map for windows stored in workspaces not present in the current bar.
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include <json/value.h>
|
#include <json/value.h>
|
||||||
#include <spdlog/spdlog.h>
|
#include <spdlog/spdlog.h>
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
@@ -95,7 +96,10 @@ void Workspace::insertWindow(WindowCreationPayload create_window_payload) {
|
|||||||
if (!create_window_payload.isEmpty(m_workspaceManager)) {
|
if (!create_window_payload.isEmpty(m_workspaceManager)) {
|
||||||
auto repr = create_window_payload.repr(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;
|
m_windowMap[create_window_payload.getAddress()] = repr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -609,6 +609,7 @@ auto Workspaces::parseConfig(const Json::Value &config) -> void {
|
|||||||
populateBoolConfig(config, "persistent-only", m_persistentOnly);
|
populateBoolConfig(config, "persistent-only", m_persistentOnly);
|
||||||
populateBoolConfig(config, "active-only", m_activeOnly);
|
populateBoolConfig(config, "active-only", m_activeOnly);
|
||||||
populateBoolConfig(config, "move-to-monitor", m_moveToMonitor);
|
populateBoolConfig(config, "move-to-monitor", m_moveToMonitor);
|
||||||
|
populateBoolConfig(config, "unique-icons", m_uniqueIcons);
|
||||||
|
|
||||||
m_persistentWorkspaceConfig = config.get("persistent-workspaces", Json::Value());
|
m_persistentWorkspaceConfig = config.get("persistent-workspaces", Json::Value());
|
||||||
populateSortByConfig(config);
|
populateSortByConfig(config);
|
||||||
@@ -1038,4 +1039,4 @@ std::optional<int> Workspaces::parseWorkspaceId(std::string const &workspaceIdSt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace waybar::modules::hyprland
|
} // namespace waybar::modules::hyprland
|
||||||
|
|||||||
@@ -139,6 +139,7 @@ TEST_CASE("Load Hyprland Workspaces bar config", "[config]") {
|
|||||||
REQUIRE(hyprland["active-only"].asBool() == true);
|
REQUIRE(hyprland["active-only"].asBool() == true);
|
||||||
REQUIRE(hyprland["all-outputs"].asBool() == false);
|
REQUIRE(hyprland["all-outputs"].asBool() == false);
|
||||||
REQUIRE(hyprland["move-to-monitor"].asBool() == true);
|
REQUIRE(hyprland["move-to-monitor"].asBool() == true);
|
||||||
|
REQUIRE(hyprland["unique-icons"].asBool() == true);
|
||||||
REQUIRE(hyprland["format"].asString() == "{icon} {windows}");
|
REQUIRE(hyprland["format"].asString() == "{icon} {windows}");
|
||||||
REQUIRE(hyprland["format-window-separator"].asString() == " ");
|
REQUIRE(hyprland["format-window-separator"].asString() == " ");
|
||||||
REQUIRE(hyprland["on-scroll-down"].asString() == "hyprctl dispatch workspace e-1");
|
REQUIRE(hyprland["on-scroll-down"].asString() == "hyprctl dispatch workspace e-1");
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
"window-rewrite": {
|
"window-rewrite": {
|
||||||
"title<Steam>": ""
|
"title<Steam>": ""
|
||||||
},
|
},
|
||||||
|
"unique-icons": true,
|
||||||
"window-rewrite-default": "",
|
"window-rewrite-default": "",
|
||||||
"window-rewrite-separator": " ",
|
"window-rewrite-separator": " ",
|
||||||
"sort-by": "number"
|
"sort-by": "number"
|
||||||
|
|||||||
Reference in New Issue
Block a user