Skip to content

Commit e30ddda

Browse files
authored
Merge pull request #2987 from tomben13/master
[hyprland/workspaces] New options to change on click behaviour and active workspace status
2 parents 38634a0 + 6888949 commit e30ddda

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

include/modules/hyprland/workspaces.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ class Workspaces : public AModule, public EventHandler {
127127
auto allOutputs() const -> bool { return m_allOutputs; }
128128
auto showSpecial() const -> bool { return m_showSpecial; }
129129
auto activeOnly() const -> bool { return m_activeOnly; }
130+
auto moveToMonitor() const -> bool { return m_moveToMonitor; }
130131

131132
auto getBarOutput() const -> std::string { return m_bar.output->name; }
132133

@@ -183,6 +184,7 @@ class Workspaces : public AModule, public EventHandler {
183184
bool m_allOutputs = false;
184185
bool m_showSpecial = false;
185186
bool m_activeOnly = false;
187+
bool m_moveToMonitor = false;
186188
Json::Value m_persistentWorkspaceConfig;
187189

188190
// Map for windows stored in workspaces not present in the current bar.

man/waybar-hyprland-workspaces.5.scd

+7
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ Addressed by *hyprland/workspaces*
5252
default: false ++
5353
If set to true, only the active workspace will be shown.
5454

55+
*move-to-monitor*: ++
56+
typeof: bool ++
57+
default: false ++
58+
If set to true, open the workspace on the current monitor when clicking on a workspace button.
59+
Otherwise, the workspace will open on the monitor where it was previously assigned.
60+
Analog to using `focusworkspaceoncurrentmonitor` dispatcher instead of `workspace` in Hyprland.
61+
5562
*ignore-workspaces*: ++
5663
typeof: array ++
5764
default: [] ++

src/modules/hyprland/workspaces.cpp

+15-2
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ auto Workspaces::parseConfig(const Json::Value &config) -> void {
8383
m_activeOnly = configActiveOnly.asBool();
8484
}
8585

86+
auto configMoveToMonitor = config_["move-to-monitor"];
87+
if (configMoveToMonitor.isBool()) {
88+
m_moveToMonitor = configMoveToMonitor.asBool();
89+
}
90+
8691
auto configSortBy = config_["sort-by"];
8792
if (configSortBy.isString()) {
8893
auto sortByStr = configSortBy.asString();
@@ -1034,9 +1039,17 @@ bool Workspace::handleClicked(GdkEventButton *bt) const {
10341039
if (bt->type == GDK_BUTTON_PRESS) {
10351040
try {
10361041
if (id() > 0) { // normal
1037-
gIPC->getSocket1Reply("dispatch workspace " + std::to_string(id()));
1042+
if (m_workspaceManager.moveToMonitor()) {
1043+
gIPC->getSocket1Reply("dispatch focusworkspaceoncurrentmonitor " + std::to_string(id()));
1044+
} else {
1045+
gIPC->getSocket1Reply("dispatch workspace " + std::to_string(id()));
1046+
}
10381047
} else if (!isSpecial()) { // named (this includes persistent)
1039-
gIPC->getSocket1Reply("dispatch workspace name:" + name());
1048+
if (m_workspaceManager.moveToMonitor()) {
1049+
gIPC->getSocket1Reply("dispatch focusworkspaceoncurrentmonitor name:" + name());
1050+
} else {
1051+
gIPC->getSocket1Reply("dispatch workspace name:" + name());
1052+
}
10401053
} else if (id() != -99) { // named special
10411054
gIPC->getSocket1Reply("dispatch togglespecialworkspace " + name());
10421055
} else { // special

0 commit comments

Comments
 (0)