Skip to content

Commit

Permalink
Merge pull request #2466 from maximbaz/hyprland-support-workspace-rename
Browse files Browse the repository at this point in the history
hyprland/workspaces: react on renameworkspace event
  • Loading branch information
Alexays committed Sep 5, 2023
2 parents f7ff005 + 9c49f46 commit 116aa5c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/modules/hyprland/workspaces.hpp
Expand Up @@ -34,6 +34,7 @@ class Workspace {
void set_persistent(bool value = true) { is_persistent_ = value; };
void set_urgent(bool value = true) { is_urgent_ = value; };
void set_windows(uint value) { windows_ = value; };
void set_name(std::string value) { name_ = value; };

void update(const std::string& format, const std::string& icon);

Expand Down
11 changes: 11 additions & 0 deletions src/modules/hyprland/workspaces.cpp
Expand Up @@ -55,6 +55,7 @@ Workspaces::Workspaces(const std::string &id, const Bar &bar, const Json::Value
gIPC->registerForIPC("destroyworkspace", this);
gIPC->registerForIPC("focusedmon", this);
gIPC->registerForIPC("moveworkspace", this);
gIPC->registerForIPC("renameworkspace", this);
gIPC->registerForIPC("openwindow", this);
gIPC->registerForIPC("closewindow", this);
gIPC->registerForIPC("movewindow", this);
Expand Down Expand Up @@ -132,6 +133,16 @@ void Workspaces::onEvent(const std::string &ev) {
update_window_count();
} else if (eventName == "urgent") {
set_urgent_workspace(payload);
} else if (eventName == "renameworkspace") {
std::string workspace_id_str = payload.substr(0, payload.find(','));
int workspace_id = workspace_id_str == "special" ? -99 : std::stoi(workspace_id_str);
std::string new_name = payload.substr(payload.find(',') + 1);
for (auto &workspace : workspaces_) {
if (workspace->id() == workspace_id) {
workspace->set_name(new_name);
break;
}
}
}

dp.emit();
Expand Down

0 comments on commit 116aa5c

Please sign in to comment.