Skip to content

Commit ca17bdb

Browse files
authored
Merge pull request #2968 from jramrath/hyprland_workspaces_monitor_class
Hyprland workspaces `hosting-monitor` css class
2 parents 376b4d1 + f014a7d commit ca17bdb

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

include/modules/hyprland/workspaces.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ class Workspace {
8585
void setVisible(bool value = true) { m_isVisible = value; };
8686
void setWindows(uint value) { m_windows = value; };
8787
void setName(std::string const& value) { m_name = value; };
88+
void setOutput(std::string const& value) { m_output = value; };
8889
bool containsWindow(WindowAddress const& addr) const { return m_windowMap.contains(addr); }
8990
void insertWindow(WindowCreationPayload create_window_paylod);
9091
std::string removeWindow(WindowAddress const& addr);

man/waybar-hyprland-workspaces.5.scd

+1
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,4 @@ Additional to workspace name matching, the following *format-icons* can be set.
158158
- *#workspaces button.persistent*
159159
- *#workspaces button.special*
160160
- *#workspaces button.urgent*
161+
- *#workspaces button.hosting-monitor* (gets applied if workspace-monitor == waybar-monitor)

src/modules/hyprland/workspaces.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ void Workspaces::doUpdate() {
208208
}
209209

210210
spdlog::trace("Updating workspace states");
211+
auto updated_workspaces = gIPC->getSocket1JsonReply("workspaces");
211212
for (auto &workspace : m_workspaces) {
212213
// active
213214
workspace->setActive(workspace->name() == m_activeWorkspaceName ||
@@ -226,6 +227,16 @@ void Workspaces::doUpdate() {
226227
if (m_withIcon) {
227228
workspaceIcon = workspace->selectIcon(m_iconsMap);
228229
}
230+
231+
// update m_output
232+
auto updated_workspace =
233+
std::find_if(updated_workspaces.begin(), updated_workspaces.end(), [&workspace](auto &w) {
234+
auto wNameRaw = w["name"].asString();
235+
auto wName = wNameRaw.starts_with("special:") ? wNameRaw.substr(8) : wNameRaw;
236+
return wName == workspace->name();
237+
});
238+
workspace->setOutput((*updated_workspace)["monitor"].asString());
239+
229240
workspace->update(m_format, workspaceIcon);
230241
}
231242

@@ -876,6 +887,7 @@ void Workspace::update(const std::string &format, const std::string &icon) {
876887
addOrRemoveClass(styleContext, isPersistent(), "persistent");
877888
addOrRemoveClass(styleContext, isUrgent(), "urgent");
878889
addOrRemoveClass(styleContext, isVisible(), "visible");
890+
addOrRemoveClass(styleContext, m_workspaceManager.getBarOutput() == output(), "hosting-monitor");
879891

880892
std::string windows;
881893
auto windowSeparator = m_workspaceManager.getWindowSeparator();

0 commit comments

Comments
 (0)