Skip to content

Commit e8cf6a8

Browse files
committed
hyprland/workspaces: allow sorting by 'output'
1 parent 41de896 commit e8cf6a8

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

include/modules/hyprland/workspaces.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,14 @@ class Workspaces : public AModule, public EventHandler {
148148
// and doesn't share windows across bars (a.k.a `all-outputs` = false)
149149
std::map<WindowAddress, WindowRepr, std::less<>> m_orphanWindowMap;
150150

151-
enum class SortMethod { ID, NAME, NUMBER, SPECIAL_CENTERED, DEFAULT };
151+
enum class SortMethod { ID, NAME, NUMBER, SPECIAL_CENTERED, OUTPUT, DEFAULT };
152152
util::EnumParser<SortMethod> m_enumParser;
153153
SortMethod m_sortBy = SortMethod::DEFAULT;
154154
std::map<std::string, SortMethod> m_sortMap = {{"ID", SortMethod::ID},
155155
{"NAME", SortMethod::NAME},
156156
{"NUMBER", SortMethod::NUMBER},
157157
{"SPECIAL-CENTERED", SortMethod::SPECIAL_CENTERED},
158+
{"OUTPUT", SortMethod::OUTPUT},
158159
{"DEFAULT", SortMethod::DEFAULT}};
159160

160161
std::string m_formatBefore;

man/waybar-hyprland-workspaces.5.scd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ This setting is ignored if *workspace-taskbar.enable* is set to true.
114114
If set to name, workspaces will sort by name.
115115
If set to id, workspaces will sort by id.
116116
If set to special-centered, workspaces will sort by default with special workspaces in the center.
117+
If set to output, workspaces will sort by the output (monitor) name.
117118
If none of those, workspaces will sort with default behavior.
118119

119120
*expand*: ++

src/modules/hyprland/workspaces.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -913,12 +913,15 @@ void Workspaces::sortWorkspaces() {
913913
// Helper comparisons
914914
auto isIdLess = a->id() < b->id();
915915
auto isNameLess = a->name() < b->name();
916+
auto isOutputLess = a->output() < b->output();
916917

917918
switch (m_sortBy) {
918919
case SortMethod::ID:
919920
return isIdLess;
920921
case SortMethod::NAME:
921922
return isNameLess;
923+
case SortMethod::OUTPUT:
924+
return isOutputLess;
922925
case SortMethod::NUMBER:
923926
try {
924927
return std::stoi(a->name()) < std::stoi(b->name());

0 commit comments

Comments
 (0)