mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
Merge pull request #1809 from herlev/hyprland-named-workspace-crash
This commit is contained in:
commit
74fa131ebe
@ -18,8 +18,8 @@ class Window : public waybar::ALabel,
|
|||||||
auto update() -> void;
|
auto update() -> void;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint getActiveWorkspaceID(std::string);
|
int getActiveWorkspaceID(std::string);
|
||||||
std::string getLastWindowTitle(uint);
|
std::string getLastWindowTitle(int);
|
||||||
void onEvent(const std::string&);
|
void onEvent(const std::string&);
|
||||||
|
|
||||||
bool separate_outputs;
|
bool separate_outputs;
|
||||||
|
@ -49,7 +49,7 @@ auto Window::update() -> void {
|
|||||||
ALabel::update();
|
ALabel::update();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint Window::getActiveWorkspaceID(std::string monitorName) {
|
int Window::getActiveWorkspaceID(std::string monitorName) {
|
||||||
auto cmd = waybar::util::command::exec("hyprctl monitors -j");
|
auto cmd = waybar::util::command::exec("hyprctl monitors -j");
|
||||||
assert(cmd.exit_code == 0);
|
assert(cmd.exit_code == 0);
|
||||||
Json::Value json = parser_.parse(cmd.out);
|
Json::Value json = parser_.parse(cmd.out);
|
||||||
@ -59,16 +59,16 @@ uint Window::getActiveWorkspaceID(std::string monitorName) {
|
|||||||
if (monitor == std::end(json)) {
|
if (monitor == std::end(json)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return (*monitor)["activeWorkspace"]["id"].as<uint>();
|
return (*monitor)["activeWorkspace"]["id"].as<int>();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Window::getLastWindowTitle(uint workspaceID) {
|
std::string Window::getLastWindowTitle(int workspaceID) {
|
||||||
auto cmd = waybar::util::command::exec("hyprctl workspaces -j");
|
auto cmd = waybar::util::command::exec("hyprctl workspaces -j");
|
||||||
assert(cmd.exit_code == 0);
|
assert(cmd.exit_code == 0);
|
||||||
Json::Value json = parser_.parse(cmd.out);
|
Json::Value json = parser_.parse(cmd.out);
|
||||||
assert(json.isArray());
|
assert(json.isArray());
|
||||||
auto workspace = std::find_if(json.begin(), json.end(), [&](Json::Value workspace) {
|
auto workspace = std::find_if(json.begin(), json.end(), [&](Json::Value workspace) {
|
||||||
return workspace["id"].as<uint>() == workspaceID;
|
return workspace["id"].as<int>() == workspaceID;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (workspace == std::end(json)) {
|
if (workspace == std::end(json)) {
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
#include <stdexcept>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "gtkmm/widget.h"
|
#include "gtkmm/widget.h"
|
||||||
@ -66,10 +67,13 @@ auto WorkspaceManager::workspace_comparator() const
|
|||||||
auto is_name_less = lhs->get_name() < rhs->get_name();
|
auto is_name_less = lhs->get_name() < rhs->get_name();
|
||||||
auto is_name_eq = lhs->get_name() == rhs->get_name();
|
auto is_name_eq = lhs->get_name() == rhs->get_name();
|
||||||
auto is_coords_less = lhs->get_coords() < rhs->get_coords();
|
auto is_coords_less = lhs->get_coords() < rhs->get_coords();
|
||||||
auto is_number_less = std::stoi(lhs->get_name()) < std::stoi(rhs->get_name());
|
|
||||||
|
|
||||||
if (sort_by_number_) {
|
if (sort_by_number_) {
|
||||||
return is_number_less;
|
try {
|
||||||
|
auto is_number_less = std::stoi(lhs->get_name()) < std::stoi(rhs->get_name());
|
||||||
|
return is_number_less;
|
||||||
|
} catch (std::invalid_argument) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sort_by_name_) {
|
if (sort_by_name_) {
|
||||||
|
Loading…
Reference in New Issue
Block a user