fix: hosting-monitor classes not recheck on monitor disconnect/waybar restart
Some checks failed
Nix-Tests / nix-flake-check (push) Has been cancelled
linux / build (c++20, alpine) (push) Has been cancelled
linux / build (c++20, archlinux) (push) Has been cancelled
linux / build (c++20, debian) (push) Has been cancelled
linux / build (c++20, fedora) (push) Has been cancelled
linux / build (c++20, gentoo) (push) Has been cancelled
linux / build (c++20, opensuse) (push) Has been cancelled
freebsd / build (push) Has been cancelled
clang-format / lint (push) Has been cancelled
Some checks failed
Nix-Tests / nix-flake-check (push) Has been cancelled
linux / build (c++20, alpine) (push) Has been cancelled
linux / build (c++20, archlinux) (push) Has been cancelled
linux / build (c++20, debian) (push) Has been cancelled
linux / build (c++20, fedora) (push) Has been cancelled
linux / build (c++20, gentoo) (push) Has been cancelled
linux / build (c++20, opensuse) (push) Has been cancelled
freebsd / build (push) Has been cancelled
clang-format / lint (push) Has been cancelled
This commit is contained in:
12
meson.build
12
meson.build
@@ -505,18 +505,6 @@ cava = dependency('libcava',
|
|||||||
|
|
||||||
eproxy = dependency('epoxy', required: false)
|
eproxy = dependency('epoxy', required: false)
|
||||||
|
|
||||||
if cava.found()
|
|
||||||
add_project_arguments('-DHAVE_LIBCAVA', language: 'cpp')
|
|
||||||
src_files += files('src/modules/cava/cavaRaw.cpp',
|
|
||||||
'src/modules/cava/cava_backend.cpp')
|
|
||||||
man_files += files('man/waybar-cava.5.scd')
|
|
||||||
|
|
||||||
if eproxy.found()
|
|
||||||
add_project_arguments('-DHAVE_LIBCAVAGLSL', language: 'cpp')
|
|
||||||
src_files += files('src/modules/cava/cavaGLSL.cpp')
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
if libgps.found()
|
if libgps.found()
|
||||||
add_project_arguments('-DHAVE_LIBGPS', language: 'cpp')
|
add_project_arguments('-DHAVE_LIBGPS', language: 'cpp')
|
||||||
src_files += files('src/modules/gps.cpp')
|
src_files += files('src/modules/gps.cpp')
|
||||||
|
|||||||
@@ -114,7 +114,7 @@
|
|||||||
#ifdef HAVE_LIBGPS
|
#ifdef HAVE_LIBGPS
|
||||||
#include "modules/gps.hpp"
|
#include "modules/gps.hpp"
|
||||||
#endif
|
#endif
|
||||||
#include "modules/cava/cava_frontend.hpp"
|
// #include "modules/cava/cava_frontend.hpp"
|
||||||
#include "modules/cffi.hpp"
|
#include "modules/cffi.hpp"
|
||||||
#include "modules/custom.hpp"
|
#include "modules/custom.hpp"
|
||||||
#include "modules/image.hpp"
|
#include "modules/image.hpp"
|
||||||
@@ -339,9 +339,6 @@ waybar::AModule* waybar::Factory::makeModule(const std::string& name,
|
|||||||
return new waybar::modules::Wireplumber(id, config_[name]);
|
return new waybar::modules::Wireplumber(id, config_[name]);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (ref == "cava") {
|
|
||||||
return waybar::modules::cava::getModule(id, config_[name]);
|
|
||||||
}
|
|
||||||
#ifdef HAVE_SYSTEMD_MONITOR
|
#ifdef HAVE_SYSTEMD_MONITOR
|
||||||
if (ref == "systemd-failed-units") {
|
if (ref == "systemd-failed-units") {
|
||||||
return new waybar::modules::SystemdFailedUnits(id, config_[name]);
|
return new waybar::modules::SystemdFailedUnits(id, config_[name]);
|
||||||
|
|||||||
@@ -11,8 +11,8 @@
|
|||||||
|
|
||||||
namespace waybar::modules::hyprland {
|
namespace waybar::modules::hyprland {
|
||||||
|
|
||||||
Workspace::Workspace(const Json::Value& workspace_data, Workspaces& workspace_manager,
|
Workspace::Workspace(const Json::Value &workspace_data, Workspaces &workspace_manager,
|
||||||
const Json::Value& clients_data)
|
const Json::Value &clients_data)
|
||||||
: m_workspaceManager(workspace_manager),
|
: m_workspaceManager(workspace_manager),
|
||||||
m_id(workspace_data["id"].asInt()),
|
m_id(workspace_data["id"].asInt()),
|
||||||
m_name(workspace_data["name"].asString()),
|
m_name(workspace_data["name"].asString()),
|
||||||
@@ -45,8 +45,8 @@ Workspace::Workspace(const Json::Value& workspace_data, Workspaces& workspace_ma
|
|||||||
initializeWindowMap(clients_data);
|
initializeWindowMap(clients_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void addOrRemoveClass(const Glib::RefPtr<Gtk::StyleContext>& context, bool condition,
|
void addOrRemoveClass(const Glib::RefPtr<Gtk::StyleContext> &context, bool condition,
|
||||||
const std::string& class_name) {
|
const std::string &class_name) {
|
||||||
if (condition) {
|
if (condition) {
|
||||||
context->add_class(class_name);
|
context->add_class(class_name);
|
||||||
} else {
|
} else {
|
||||||
@@ -54,9 +54,9 @@ void addOrRemoveClass(const Glib::RefPtr<Gtk::StyleContext>& context, bool condi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<WindowRepr> Workspace::closeWindow(WindowAddress const& addr) {
|
std::optional<WindowRepr> Workspace::closeWindow(WindowAddress const &addr) {
|
||||||
auto it = std::ranges::find_if(m_windowMap,
|
auto it = std::ranges::find_if(m_windowMap,
|
||||||
[&addr](const auto& window) { return window.address == addr; });
|
[&addr](const auto &window) { return window.address == addr; });
|
||||||
// If the vector contains the address, remove it and return the window representation
|
// If the vector contains the address, remove it and return the window representation
|
||||||
if (it != m_windowMap.end()) {
|
if (it != m_windowMap.end()) {
|
||||||
WindowRepr windowRepr = *it;
|
WindowRepr windowRepr = *it;
|
||||||
@@ -66,7 +66,7 @@ std::optional<WindowRepr> Workspace::closeWindow(WindowAddress const& addr) {
|
|||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Workspace::handleClicked(GdkEventButton* bt) const {
|
bool Workspace::handleClicked(GdkEventButton *bt) const {
|
||||||
if (bt->type == GDK_BUTTON_PRESS) {
|
if (bt->type == GDK_BUTTON_PRESS) {
|
||||||
try {
|
try {
|
||||||
if (id() > 0) { // normal
|
if (id() > 0) { // normal
|
||||||
@@ -87,14 +87,14 @@ bool Workspace::handleClicked(GdkEventButton* bt) const {
|
|||||||
m_ipc.getSocket1Reply("dispatch togglespecialworkspace");
|
m_ipc.getSocket1Reply("dispatch togglespecialworkspace");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception &e) {
|
||||||
spdlog::error("Failed to dispatch workspace: {}", e.what());
|
spdlog::error("Failed to dispatch workspace: {}", e.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Workspace::initializeWindowMap(const Json::Value& clients_data) {
|
void Workspace::initializeWindowMap(const Json::Value &clients_data) {
|
||||||
m_windowMap.clear();
|
m_windowMap.clear();
|
||||||
for (auto client : clients_data) {
|
for (auto client : clients_data) {
|
||||||
if (client["workspace"]["id"].asInt() == id()) {
|
if (client["workspace"]["id"].asInt() == id()) {
|
||||||
@@ -103,10 +103,10 @@ void Workspace::initializeWindowMap(const Json::Value& clients_data) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Workspace::setActiveWindow(WindowAddress const& addr) {
|
void Workspace::setActiveWindow(WindowAddress const &addr) {
|
||||||
std::optional<long> activeIdx;
|
std::optional<long> activeIdx;
|
||||||
for (size_t i = 0; i < m_windowMap.size(); ++i) {
|
for (size_t i = 0; i < m_windowMap.size(); ++i) {
|
||||||
auto& window = m_windowMap[i];
|
auto &window = m_windowMap[i];
|
||||||
bool isActive = (window.address == addr);
|
bool isActive = (window.address == addr);
|
||||||
window.setActive(isActive);
|
window.setActive(isActive);
|
||||||
if (isActive) {
|
if (isActive) {
|
||||||
@@ -133,7 +133,7 @@ void Workspace::insertWindow(WindowCreationPayload create_window_payload) {
|
|||||||
if (!repr.empty() || m_workspaceManager.enableTaskbar()) {
|
if (!repr.empty() || m_workspaceManager.enableTaskbar()) {
|
||||||
auto addr = create_window_payload.getAddress();
|
auto addr = create_window_payload.getAddress();
|
||||||
auto it = std::ranges::find_if(
|
auto it = std::ranges::find_if(
|
||||||
m_windowMap, [&addr](const auto& window) { return window.address == addr; });
|
m_windowMap, [&addr](const auto &window) { return window.address == addr; });
|
||||||
// If the vector contains the address, update the window representation, otherwise insert it
|
// If the vector contains the address, update the window representation, otherwise insert it
|
||||||
if (it != m_windowMap.end()) {
|
if (it != m_windowMap.end()) {
|
||||||
*it = repr;
|
*it = repr;
|
||||||
@@ -144,7 +144,7 @@ void Workspace::insertWindow(WindowCreationPayload create_window_payload) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
bool Workspace::onWindowOpened(WindowCreationPayload const& create_window_payload) {
|
bool Workspace::onWindowOpened(WindowCreationPayload const &create_window_payload) {
|
||||||
if (create_window_payload.getWorkspaceName() == name()) {
|
if (create_window_payload.getWorkspaceName() == name()) {
|
||||||
insertWindow(create_window_payload);
|
insertWindow(create_window_payload);
|
||||||
return true;
|
return true;
|
||||||
@@ -152,7 +152,7 @@ bool Workspace::onWindowOpened(WindowCreationPayload const& create_window_payloa
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string& Workspace::selectIcon(std::map<std::string, std::string>& icons_map) {
|
std::string &Workspace::selectIcon(std::map<std::string, std::string> &icons_map) {
|
||||||
spdlog::trace("Selecting icon for workspace {}", name());
|
spdlog::trace("Selecting icon for workspace {}", name());
|
||||||
if (isUrgent()) {
|
if (isUrgent()) {
|
||||||
auto urgentIconIt = icons_map.find("urgent");
|
auto urgentIconIt = icons_map.find("urgent");
|
||||||
@@ -209,7 +209,7 @@ std::string& Workspace::selectIcon(std::map<std::string, std::string>& icons_map
|
|||||||
return m_name;
|
return m_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Workspace::update(const std::string& workspace_icon) {
|
void Workspace::update(const std::string &workspace_icon) {
|
||||||
if (this->m_workspaceManager.persistentOnly() && !this->isPersistent()) {
|
if (this->m_workspaceManager.persistentOnly() && !this->isPersistent()) {
|
||||||
m_button.hide();
|
m_button.hide();
|
||||||
return;
|
return;
|
||||||
@@ -248,7 +248,7 @@ void Workspace::update(const std::string& workspace_icon) {
|
|||||||
|
|
||||||
bool isNotFirst = false;
|
bool isNotFirst = false;
|
||||||
|
|
||||||
for (const auto& window_repr : m_windowMap) {
|
for (const auto &window_repr : m_windowMap) {
|
||||||
if (isNotFirst) {
|
if (isNotFirst) {
|
||||||
windows.append(windowSeparator);
|
windows.append(windowSeparator);
|
||||||
}
|
}
|
||||||
@@ -270,24 +270,16 @@ void Workspace::update(const std::string& workspace_icon) {
|
|||||||
|
|
||||||
bool Workspace::isEmpty() const {
|
bool Workspace::isEmpty() const {
|
||||||
auto ignore_list = m_workspaceManager.getIgnoredWindows();
|
auto ignore_list = m_workspaceManager.getIgnoredWindows();
|
||||||
|
|
||||||
// If there are no windows at all, the workspace is empty
|
|
||||||
if (m_windowMap.empty()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If no windows are ignored, any window means the workspace is not empty
|
|
||||||
if (ignore_list.empty()) {
|
if (ignore_list.empty()) {
|
||||||
return false;
|
return m_windows == 0;
|
||||||
}
|
}
|
||||||
|
// If there are windows but they are all ignored, consider the workspace empty
|
||||||
// Otherwise, check if every window in the map should be skipped (ignored)
|
|
||||||
return std::all_of(
|
return std::all_of(
|
||||||
m_windowMap.begin(), m_windowMap.end(),
|
m_windowMap.begin(), m_windowMap.end(),
|
||||||
[this, &ignore_list](const auto& window_repr) { return shouldSkipWindow(window_repr); });
|
[this, &ignore_list](const auto &window_repr) { return shouldSkipWindow(window_repr); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void Workspace::updateTaskbar(const std::string& workspace_icon) {
|
void Workspace::updateTaskbar(const std::string &workspace_icon) {
|
||||||
for (auto child : m_content.get_children()) {
|
for (auto child : m_content.get_children()) {
|
||||||
if (child != &m_labelBefore) {
|
if (child != &m_labelBefore) {
|
||||||
m_content.remove(*child);
|
m_content.remove(*child);
|
||||||
@@ -295,7 +287,7 @@ void Workspace::updateTaskbar(const std::string& workspace_icon) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool isFirst = true;
|
bool isFirst = true;
|
||||||
auto processWindow = [&](const WindowRepr& window_repr) {
|
auto processWindow = [&](const WindowRepr &window_repr) {
|
||||||
if (shouldSkipWindow(window_repr)) {
|
if (shouldSkipWindow(window_repr)) {
|
||||||
return; // skip
|
return; // skip
|
||||||
}
|
}
|
||||||
@@ -308,7 +300,7 @@ void Workspace::updateTaskbar(const std::string& workspace_icon) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto window_box = Gtk::make_managed<Gtk::Box>(Gtk::ORIENTATION_HORIZONTAL);
|
auto window_box = Gtk::make_managed<Gtk::Box>(Gtk::ORIENTATION_HORIZONTAL);
|
||||||
window_box->set_tooltip_markup(window_repr.window_title);
|
window_box->set_tooltip_text(window_repr.window_title);
|
||||||
window_box->get_style_context()->add_class("taskbar-window");
|
window_box->get_style_context()->add_class("taskbar-window");
|
||||||
if (window_repr.isActive) {
|
if (window_repr.isActive) {
|
||||||
window_box->get_style_context()->add_class("active");
|
window_box->get_style_context()->add_class("active");
|
||||||
@@ -351,7 +343,7 @@ void Workspace::updateTaskbar(const std::string& workspace_icon) {
|
|||||||
processWindow(*it);
|
processWindow(*it);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (const auto& window_repr : m_windowMap) {
|
for (const auto &window_repr : m_windowMap) {
|
||||||
processWindow(window_repr);
|
processWindow(window_repr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -366,7 +358,7 @@ void Workspace::updateTaskbar(const std::string& workspace_icon) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Workspace::handleClick(const GdkEventButton* event_button, WindowAddress const& addr) const {
|
bool Workspace::handleClick(const GdkEventButton *event_button, WindowAddress const &addr) const {
|
||||||
if (event_button->type == GDK_BUTTON_PRESS) {
|
if (event_button->type == GDK_BUTTON_PRESS) {
|
||||||
std::string command = std::regex_replace(m_workspaceManager.onClickWindow(),
|
std::string command = std::regex_replace(m_workspaceManager.onClickWindow(),
|
||||||
std::regex("\\{address\\}"), "0x" + addr);
|
std::regex("\\{address\\}"), "0x" + addr);
|
||||||
@@ -380,9 +372,9 @@ bool Workspace::handleClick(const GdkEventButton* event_button, WindowAddress co
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Workspace::shouldSkipWindow(const WindowRepr& window_repr) const {
|
bool Workspace::shouldSkipWindow(const WindowRepr &window_repr) const {
|
||||||
auto ignore_list = m_workspaceManager.getIgnoredWindows();
|
auto ignore_list = m_workspaceManager.getIgnoredWindows();
|
||||||
auto it = std::ranges::find_if(ignore_list, [&window_repr](const auto& ignoreItem) {
|
auto it = std::ranges::find_if(ignore_list, [&window_repr](const auto &ignoreItem) {
|
||||||
return std::regex_match(window_repr.window_class, ignoreItem) ||
|
return std::regex_match(window_repr.window_class, ignoreItem) ||
|
||||||
std::regex_match(window_repr.window_title, ignoreItem);
|
std::regex_match(window_repr.window_title, ignoreItem);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user