Merge pull request #2429 from khaneliman/hyprland-urgent
Hyprland urgent class supportpull/2248/merge
commit
b665843085
76
flake.lock
76
flake.lock
|
@ -2,15 +2,15 @@
|
||||||
"nodes": {
|
"nodes": {
|
||||||
"devshell": {
|
"devshell": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"flake-utils": "flake-utils",
|
"nixpkgs": "nixpkgs",
|
||||||
"nixpkgs": "nixpkgs"
|
"systems": "systems"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1676293499,
|
"lastModified": 1692523566,
|
||||||
"narHash": "sha256-uIOTlTxvrXxpKeTvwBI1JGDGtCxMXE3BI0LFwoQMhiQ=",
|
"narHash": "sha256-VDJDihK6jNebVw9y3qKCVD6+6QaC/x8kxZzL4MaIPPY=",
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"repo": "devshell",
|
"repo": "devshell",
|
||||||
"rev": "71e3022e3ab20bbf1342640547ef5bc14fb43bf4",
|
"rev": "d208c58e2f7afef838add5f18a9936b12a71d695",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -36,27 +36,15 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"flake-utils": {
|
"flake-utils": {
|
||||||
"locked": {
|
"inputs": {
|
||||||
"lastModified": 1642700792,
|
"systems": "systems_2"
|
||||||
"narHash": "sha256-XqHrk7hFb+zBvRg6Ghl+AZDq03ov6OshJLiSWOoX5es=",
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"rev": "846b2ae0fc4cc943637d3d1def4454213e203cba",
|
|
||||||
"type": "github"
|
|
||||||
},
|
},
|
||||||
"original": {
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"flake-utils_2": {
|
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1676283394,
|
"lastModified": 1689068808,
|
||||||
"narHash": "sha256-XX2f9c3iySLCw54rJ/CZs+ZK6IQy7GXNY4nSOyu2QG4=",
|
"narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=",
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"repo": "flake-utils",
|
"repo": "flake-utils",
|
||||||
"rev": "3db36a8b464d0c4532ba1c7dda728f4576d6d073",
|
"rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -67,11 +55,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1643381941,
|
"lastModified": 1677383253,
|
||||||
"narHash": "sha256-pHTwvnN4tTsEKkWlXQ8JMY423epos8wUOhthpwJjtpc=",
|
"narHash": "sha256-UfpzWfSxkfXHnb4boXZNaKsAcUrZT9Hw+tao1oZxd08=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "5efc8ca954272c4376ac929f4c5ffefcc20551d5",
|
"rev": "9952d6bc395f5841262b006fbace8dd7e143b634",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -83,11 +71,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs_2": {
|
"nixpkgs_2": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1676300157,
|
"lastModified": 1692638711,
|
||||||
"narHash": "sha256-1HjRzfp6LOLfcj/HJHdVKWAkX9QRAouoh6AjzJiIerU=",
|
"narHash": "sha256-J0LgSFgJVGCC1+j5R2QndadWI1oumusg6hCtYAzLID4=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "545c7a31e5dedea4a6d372712a18e00ce097d462",
|
"rev": "91a22f76cd1716f9d0149e8a5c68424bb691de15",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -101,9 +89,39 @@
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"devshell": "devshell",
|
"devshell": "devshell",
|
||||||
"flake-compat": "flake-compat",
|
"flake-compat": "flake-compat",
|
||||||
"flake-utils": "flake-utils_2",
|
"flake-utils": "flake-utils",
|
||||||
"nixpkgs": "nixpkgs_2"
|
"nixpkgs": "nixpkgs_2"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"systems": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1681028828,
|
||||||
|
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"systems_2": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1681028828,
|
||||||
|
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"root": "root",
|
"root": "root",
|
||||||
|
|
10
flake.nix
10
flake.nix
|
@ -47,17 +47,12 @@
|
||||||
let pkgs = import nixpkgs {
|
let pkgs = import nixpkgs {
|
||||||
inherit system;
|
inherit system;
|
||||||
|
|
||||||
overlays = [ devshell.overlay ];
|
overlays = [ devshell.overlays.default ];
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
pkgs.devshell.mkShell {
|
pkgs.devshell.mkShell {
|
||||||
imports = [ "${pkgs.devshell.extraModulesDir}/language/c.nix" ];
|
imports = [ "${pkgs.devshell.extraModulesDir}/language/c.nix" ];
|
||||||
commands = [
|
|
||||||
{
|
|
||||||
package = pkgs.devshell.cli;
|
|
||||||
help = "Per project developer environments";
|
|
||||||
}
|
|
||||||
];
|
|
||||||
devshell.packages = with pkgs; [
|
devshell.packages = with pkgs; [
|
||||||
clang-tools
|
clang-tools
|
||||||
gdb
|
gdb
|
||||||
|
@ -79,6 +74,7 @@
|
||||||
at-spi2-atk atkmm cairo cairomm catch2 fmt_8 fontconfig
|
at-spi2-atk atkmm cairo cairomm catch2 fmt_8 fontconfig
|
||||||
gdk-pixbuf glibmm gtk3 harfbuzz pango pangomm wayland-protocols
|
gdk-pixbuf glibmm gtk3 harfbuzz pango pangomm wayland-protocols
|
||||||
]);
|
]);
|
||||||
|
|
||||||
env = with pkgs; [
|
env = with pkgs; [
|
||||||
{ name = "CPLUS_INCLUDE_PATH"; prefix = "$DEVSHELL_DIR/include"; }
|
{ name = "CPLUS_INCLUDE_PATH"; prefix = "$DEVSHELL_DIR/include"; }
|
||||||
{ name = "PKG_CONFIG_PATH"; prefix = "$DEVSHELL_DIR/lib/pkgconfig"; }
|
{ name = "PKG_CONFIG_PATH"; prefix = "$DEVSHELL_DIR/lib/pkgconfig"; }
|
||||||
|
|
|
@ -22,10 +22,12 @@ class Workspace {
|
||||||
bool is_special() const { return is_special_; };
|
bool is_special() const { return is_special_; };
|
||||||
bool is_persistent() const { return is_persistent_; };
|
bool is_persistent() const { return is_persistent_; };
|
||||||
bool is_empty() const { return windows_ == 0; };
|
bool is_empty() const { return windows_ == 0; };
|
||||||
|
bool is_urgent() const { return is_urgent_; };
|
||||||
|
|
||||||
auto handle_clicked(GdkEventButton* bt) -> bool;
|
auto handle_clicked(GdkEventButton* bt) -> bool;
|
||||||
void set_active(bool value = true) { active_ = value; };
|
void set_active(bool value = true) { active_ = value; };
|
||||||
void set_persistent(bool value = true) { is_persistent_ = value; };
|
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_windows(uint value) { windows_ = value; };
|
||||||
|
|
||||||
void update(const std::string& format, const std::string& icon);
|
void update(const std::string& format, const std::string& icon);
|
||||||
|
@ -38,6 +40,7 @@ class Workspace {
|
||||||
bool active_ = false;
|
bool active_ = false;
|
||||||
bool is_special_ = false;
|
bool is_special_ = false;
|
||||||
bool is_persistent_ = false;
|
bool is_persistent_ = false;
|
||||||
|
bool is_urgent_ = false;
|
||||||
|
|
||||||
Gtk::Button button_;
|
Gtk::Button button_;
|
||||||
Gtk::Box content_;
|
Gtk::Box content_;
|
||||||
|
@ -62,6 +65,7 @@ class Workspaces : public AModule, public EventHandler {
|
||||||
void sort_workspaces();
|
void sort_workspaces();
|
||||||
void create_workspace(Json::Value& value);
|
void create_workspace(Json::Value& value);
|
||||||
void remove_workspace(std::string name);
|
void remove_workspace(std::string name);
|
||||||
|
void set_urgent_workspace(std::string windowaddress);
|
||||||
|
|
||||||
bool all_outputs_ = false;
|
bool all_outputs_ = false;
|
||||||
bool show_special_ = false;
|
bool show_special_ = false;
|
||||||
|
|
|
@ -76,3 +76,4 @@ Additional to workspace name matching, the following *format-icons* can be set.
|
||||||
- *#workspaces button.active*
|
- *#workspaces button.active*
|
||||||
- *#workspaces button.persistent*
|
- *#workspaces button.persistent*
|
||||||
- *#workspaces button.special*
|
- *#workspaces button.special*
|
||||||
|
- *#workspaces button.urgent*
|
||||||
|
|
|
@ -58,6 +58,7 @@ Workspaces::Workspaces(const std::string &id, const Bar &bar, const Json::Value
|
||||||
gIPC->registerForIPC("openwindow", this);
|
gIPC->registerForIPC("openwindow", this);
|
||||||
gIPC->registerForIPC("closewindow", this);
|
gIPC->registerForIPC("closewindow", this);
|
||||||
gIPC->registerForIPC("movewindow", this);
|
gIPC->registerForIPC("movewindow", this);
|
||||||
|
gIPC->registerForIPC("urgent", this);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Workspaces::update() -> void {
|
auto Workspaces::update() -> void {
|
||||||
|
@ -75,6 +76,9 @@ auto Workspaces::update() -> void {
|
||||||
|
|
||||||
for (auto &workspace : workspaces_) {
|
for (auto &workspace : workspaces_) {
|
||||||
workspace->set_active(workspace->name() == active_workspace_name_);
|
workspace->set_active(workspace->name() == active_workspace_name_);
|
||||||
|
if (workspace->name() == active_workspace_name_ && workspace.get()->is_urgent()) {
|
||||||
|
workspace->set_urgent(false);
|
||||||
|
}
|
||||||
std::string &workspace_icon = icons_map_[""];
|
std::string &workspace_icon = icons_map_[""];
|
||||||
if (with_icon_) {
|
if (with_icon_) {
|
||||||
workspace_icon = workspace->select_icon(icons_map_);
|
workspace_icon = workspace->select_icon(icons_map_);
|
||||||
|
@ -126,6 +130,8 @@ void Workspaces::onEvent(const std::string &ev) {
|
||||||
}
|
}
|
||||||
} else if (eventName == "openwindow" || eventName == "closewindow" || eventName == "movewindow") {
|
} else if (eventName == "openwindow" || eventName == "closewindow" || eventName == "movewindow") {
|
||||||
update_window_count();
|
update_window_count();
|
||||||
|
} else if (eventName == "urgent") {
|
||||||
|
set_urgent_workspace(payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
dp.emit();
|
dp.emit();
|
||||||
|
@ -323,6 +329,7 @@ void Workspace::update(const std::string &format, const std::string &icon) {
|
||||||
add_or_remove_class(style_context, active(), "active");
|
add_or_remove_class(style_context, active(), "active");
|
||||||
add_or_remove_class(style_context, is_special(), "special");
|
add_or_remove_class(style_context, is_special(), "special");
|
||||||
add_or_remove_class(style_context, is_empty(), "persistent");
|
add_or_remove_class(style_context, is_empty(), "persistent");
|
||||||
|
add_or_remove_class(style_context, is_urgent(), "urgent");
|
||||||
|
|
||||||
label_.set_markup(fmt::format(fmt::runtime(format), fmt::arg("id", id()),
|
label_.set_markup(fmt::format(fmt::runtime(format), fmt::arg("id", id()),
|
||||||
fmt::arg("name", name()), fmt::arg("icon", icon)));
|
fmt::arg("name", name()), fmt::arg("icon", icon)));
|
||||||
|
@ -419,4 +426,23 @@ auto Workspace::handle_clicked(GdkEventButton *bt) -> bool {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Workspaces::set_urgent_workspace(std::string windowaddress) {
|
||||||
|
const Json::Value clients_json = gIPC->getSocket1JsonReply("clients");
|
||||||
|
int workspace_id;
|
||||||
|
|
||||||
|
for (Json::Value client_json : clients_json) {
|
||||||
|
if (client_json["address"].asString().ends_with(windowaddress)) {
|
||||||
|
workspace_id = client_json["workspace"]["id"].asInt();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
auto workspace =
|
||||||
|
std::find_if(workspaces_.begin(), workspaces_.end(),
|
||||||
|
[&](std::unique_ptr<Workspace> &x) { return x->id() == workspace_id; });
|
||||||
|
if (workspace->get() != nullptr) {
|
||||||
|
workspace->get()->set_urgent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace waybar::modules::hyprland
|
} // namespace waybar::modules::hyprland
|
||||||
|
|
Loading…
Reference in New Issue