From 81fb0daad2a666eb34ebe7b52453b94be0a9263e Mon Sep 17 00:00:00 2001 From: Adrian Perez Date: Tue, 3 Jun 2025 16:12:30 -0700 Subject: [PATCH 01/21] feat: add a way to override electron app tray icons --- src/modules/sni/item.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/modules/sni/item.cpp b/src/modules/sni/item.cpp index 9dc13158..3b9a3dbd 100644 --- a/src/modules/sni/item.cpp +++ b/src/modules/sni/item.cpp @@ -1,3 +1,4 @@ +#include #include "modules/sni/item.hpp" #include @@ -140,7 +141,25 @@ void Item::setProperty(const Glib::ustring& name, Glib::VariantBase& value) { category = get_variant(value); } else if (name == "Id") { id = get_variant(value); - setCustomIcon(id); + + /* + * HACK: Electron apps seem to have the same ID, but tooltip seems correct, so use that as ID + * to pass as the custom icon option. I'm avoiding being disruptive and setting that to the ID + * itself as I've no idea what this would affect. + * The tooltip text is converted to lowercase since that's what (most?) themes expect? + * I still haven't found a way for it to pick from theme automatically, although + * it might be my theme. + */ + if (id == "chrome_status_icon_1") { + Glib::VariantBase value; + this->proxy_->get_cached_property(value, "ToolTip"); + tooltip = get_variant(value); + if (!tooltip.text.empty()) { + setCustomIcon(tooltip.text.lowercase()); + } + } else { + setCustomIcon(id); + } } else if (name == "Title") { title = get_variant(value); if (tooltip.text.empty()) { @@ -203,6 +222,8 @@ void Item::setStatus(const Glib::ustring& value) { } void Item::setCustomIcon(const std::string& id) { + spdlog::debug("SNI tray id: {}", id); + std::string custom_icon = IconManager::instance().getIconForApp(id); if (!custom_icon.empty()) { if (std::filesystem::exists(custom_icon)) { From 9ef6dc7380f863573346c25524f8cc7884d381d1 Mon Sep 17 00:00:00 2001 From: Skylar Abruzese Date: Thu, 3 Jul 2025 17:44:37 -0400 Subject: [PATCH 02/21] fix: hyprland named persistent workspaces allowed persistent workspaces to be defined with names instead of just id's --- src/modules/hyprland/workspaces.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/modules/hyprland/workspaces.cpp b/src/modules/hyprland/workspaces.cpp index bb03f707..8dcd9b0e 100644 --- a/src/modules/hyprland/workspaces.cpp +++ b/src/modules/hyprland/workspaces.cpp @@ -253,10 +253,8 @@ void Workspaces::loadPersistentWorkspacesFromConfig(Json::Value const &clientsJs // value is an array => create defined workspaces for this monitor if (canCreate) { for (const Json::Value &workspace : value) { - if (workspace.isInt()) { - spdlog::debug("Creating workspace {} on monitor {}", workspace, currentMonitor); - persistentWorkspacesToCreate.emplace_back(std::to_string(workspace.asInt())); - } + spdlog::debug("Creating workspace {} on monitor {}", workspace, currentMonitor); + persistentWorkspacesToCreate.emplace_back(workspace.asString()); } } else { // key is the workspace and value is array of monitors to create on From 6d3b93bbf7e6f069a3c3f8539745989938a4dfea Mon Sep 17 00:00:00 2001 From: Skylar Abruzese Date: Thu, 3 Jul 2025 18:48:04 -0400 Subject: [PATCH 03/21] fix: added active workspace matching by name as fallback fixes bug where persistent workspaces would not be marked as active because their id is based on creation time by hyprland and thus we can't consistently match the id's without constantly changing them (this would also cause issues with workspace sorting). --- src/modules/hyprland/workspaces.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/modules/hyprland/workspaces.cpp b/src/modules/hyprland/workspaces.cpp index 8dcd9b0e..1f61e267 100644 --- a/src/modules/hyprland/workspaces.cpp +++ b/src/modules/hyprland/workspaces.cpp @@ -942,9 +942,17 @@ bool Workspaces::updateWindowsToCreate() { void Workspaces::updateWorkspaceStates() { const std::vector visibleWorkspaces = getVisibleWorkspaces(); auto updatedWorkspaces = m_ipc.getSocket1JsonReply("workspaces"); + + auto currentWorkspace = m_ipc.getSocket1JsonReply("activeworkspace"); + std::string currentWorkspaceName = + currentWorkspace.isMember("name") ? currentWorkspace["name"].asString() : ""; + for (auto &workspace : m_workspaces) { + bool isActiveByName = + !currentWorkspaceName.empty() && workspace->name() == currentWorkspaceName; + workspace->setActive( - workspace->id() == m_activeWorkspaceId || + workspace->id() == m_activeWorkspaceId || isActiveByName || (workspace->isSpecial() && workspace->name() == m_activeSpecialWorkspaceName)); if (workspace->isActive() && workspace->isUrgent()) { workspace->setUrgent(false); From fd670026627dde73a5eab68dc053c7c9e671742e Mon Sep 17 00:00:00 2001 From: Andy Carlson <2yinyang2@gmail.com> Date: Sun, 6 Jul 2025 23:11:00 -0400 Subject: [PATCH 04/21] fix: prevent persistent workspaces from being duplicated if they exist under a different name --- src/modules/hyprland/workspaces.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/modules/hyprland/workspaces.cpp b/src/modules/hyprland/workspaces.cpp index bb03f707..49ab885e 100644 --- a/src/modules/hyprland/workspaces.cpp +++ b/src/modules/hyprland/workspaces.cpp @@ -65,11 +65,15 @@ Json::Value Workspaces::createMonitorWorkspaceData(std::string const &name, void Workspaces::createWorkspace(Json::Value const &workspace_data, Json::Value const &clients_data) { auto workspaceName = workspace_data["name"].asString(); + auto workspaceId = workspace_data["id"].asInt(); spdlog::debug("Creating workspace {}", workspaceName); // avoid recreating existing workspaces auto workspace = - std::ranges::find_if(m_workspaces, [workspaceName](std::unique_ptr const &w) { + std::ranges::find_if(m_workspaces, [&](std::unique_ptr const &w) { + if (workspaceId > 0) { + return w->id() == workspaceId; + } return (workspaceName.starts_with("special:") && workspaceName.substr(8) == w->name()) || workspaceName == w->name(); }); From 310a473e65c4a0e0dd380f1a6ece0e2cc5774d36 Mon Sep 17 00:00:00 2001 From: hritix Date: Wed, 9 Jul 2025 22:50:03 +0530 Subject: [PATCH 05/21] enabled markup support for tooltip of battery and pulseaudio modules --- src/modules/battery.cpp | 2 +- src/modules/pulseaudio.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/battery.cpp b/src/modules/battery.cpp index 32488d53..3d0da330 100644 --- a/src/modules/battery.cpp +++ b/src/modules/battery.cpp @@ -704,7 +704,7 @@ auto waybar::modules::Battery::update() -> void { } else if (config_["tooltip-format"].isString()) { tooltip_format = config_["tooltip-format"].asString(); } - label_.set_tooltip_text( + label_.set_tooltip_markup( fmt::format(fmt::runtime(tooltip_format), fmt::arg("timeTo", tooltip_text_default), fmt::arg("power", power), fmt::arg("capacity", capacity), fmt::arg("time", time_remaining_formatted), fmt::arg("cycles", cycles), diff --git a/src/modules/pulseaudio.cpp b/src/modules/pulseaudio.cpp index 255ca571..ceed20dd 100644 --- a/src/modules/pulseaudio.cpp +++ b/src/modules/pulseaudio.cpp @@ -132,7 +132,7 @@ auto waybar::modules::Pulseaudio::update() -> void { tooltip_format = config_["tooltip-format"].asString(); } if (!tooltip_format.empty()) { - label_.set_tooltip_text(fmt::format( + label_.set_tooltip_markup(fmt::format( fmt::runtime(tooltip_format), fmt::arg("desc", sink_desc), fmt::arg("volume", sink_volume), fmt::arg("format_source", format_source), fmt::arg("source_volume", source_volume), fmt::arg("source_desc", source_desc), From 46a152abc8fe006be2d7a48e85d8c42d8aabffb8 Mon Sep 17 00:00:00 2001 From: peelz Date: Tue, 1 Jul 2025 23:40:42 -0400 Subject: [PATCH 06/21] fix(network): display as disabled if rfkill and no carrier We want the "disabled" state even when an interface is selected explicitly. --- src/modules/network.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/modules/network.cpp b/src/modules/network.cpp index cc096f72..6548e420 100644 --- a/src/modules/network.cpp +++ b/src/modules/network.cpp @@ -271,11 +271,12 @@ void waybar::modules::Network::worker() { } const std::string waybar::modules::Network::getNetworkState() const { + if (ifid_ == -1 || !carrier_) { #ifdef WANT_RFKILL - if (rfkill_.getState() && ifid_ == -1) return "disabled"; + if (rfkill_.getState()) return "disabled"; #endif - if (ifid_ == -1) return "disconnected"; - if (!carrier_) return "disconnected"; + return "disconnected"; + } if (ipaddr_.empty() && ipaddr6_.empty()) return "linked"; if (essid_.empty()) return "ethernet"; return "wifi"; From 0e07c7ac5c61abcf842106a4258ef823b9cefcc6 Mon Sep 17 00:00:00 2001 From: peelz Date: Tue, 1 Jul 2025 23:40:42 -0400 Subject: [PATCH 07/21] feat(network): add rfkill setting This setting makes it possible to have a configuration with two network modules where one of them displays the ethernet state (disconnected, linked, ethernet), and the other, the wifi state (disabled, disconnected, linked, wifi). Otherwise the ethernet state would show up as "disabled" (instead of "disconnected") when rfkill is active. --- man/waybar-network.5.scd | 9 +++++++-- src/modules/network.cpp | 6 +++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/man/waybar-network.5.scd b/man/waybar-network.5.scd index 3b63e3ee..11cf18f0 100644 --- a/man/waybar-network.5.scd +++ b/man/waybar-network.5.scd @@ -16,6 +16,11 @@ Addressed by *network* typeof: string ++ Use the defined interface instead of auto-detection. Accepts wildcard. +*rfkill*: ++ + typeof: bool ++ + default: true ++ + If enabled, the *disabled* format will be used when rfkill is blocking wlan interfaces. + *interval*: ++ typeof: integer ++ default: 60 ++ @@ -49,7 +54,7 @@ Addressed by *network* *format-disabled*: ++ typeof: string ++ - This format is used when the displayed interface is disabled. + This format is used when rfkill is blocking wlan interfaces. *format-icons*: ++ typeof: array/object ++ @@ -127,7 +132,7 @@ Addressed by *network* *tooltip-format-disabled*: ++ typeof: string ++ - This format is used when the displayed interface is disabled. + This format is used when rfkill is blocking wlan interfaces. *menu*: ++ typeof: string ++ diff --git a/src/modules/network.cpp b/src/modules/network.cpp index 6548e420..ca441bd5 100644 --- a/src/modules/network.cpp +++ b/src/modules/network.cpp @@ -273,7 +273,11 @@ void waybar::modules::Network::worker() { const std::string waybar::modules::Network::getNetworkState() const { if (ifid_ == -1 || !carrier_) { #ifdef WANT_RFKILL - if (rfkill_.getState()) return "disabled"; + bool display_rfkill = true; + if (config_["rfkill"].isBool()) { + display_rfkill = config_["rfkill"].asBool(); + } + if (rfkill_.getState() && display_rfkill) return "disabled"; #endif return "disconnected"; } From f991af2893aabe1fb71495698cbc582048805c6b Mon Sep 17 00:00:00 2001 From: peelz Date: Tue, 1 Jul 2025 23:41:22 -0400 Subject: [PATCH 08/21] style(network): fix trailing white space --- man/waybar-network.5.scd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/waybar-network.5.scd b/man/waybar-network.5.scd index 11cf18f0..9e146ac0 100644 --- a/man/waybar-network.5.scd +++ b/man/waybar-network.5.scd @@ -162,7 +162,7 @@ Addressed by *network* *{netmask}*: The subnetmask corresponding to the IP(V4). -*{netmask6}*: The subnetmask corresponding to the IP(V6). +*{netmask6}*: The subnetmask corresponding to the IP(V6). *{cidr}*: The subnetmask corresponding to the IP(V4) in CIDR notation. From 2dfbaabf31eeb8637380f2870db18017347bf8e6 Mon Sep 17 00:00:00 2001 From: peelz Date: Thu, 3 Jul 2025 15:13:37 -0400 Subject: [PATCH 09/21] fix(network): use atomic_bool to store the rfkill state --- include/util/rfkill.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/util/rfkill.hpp b/include/util/rfkill.hpp index f620db53..47ab729b 100644 --- a/include/util/rfkill.hpp +++ b/include/util/rfkill.hpp @@ -5,6 +5,8 @@ #include #include +#include + namespace waybar::util { class Rfkill : public sigc::trackable { @@ -17,7 +19,7 @@ class Rfkill : public sigc::trackable { private: enum rfkill_type rfkill_type_; - bool state_ = false; + std::atomic_bool state_ = false; int fd_ = -1; bool on_event(Glib::IOCondition cond); From b02694caef5bdb4509eaf5d5db0593114ce739fa Mon Sep 17 00:00:00 2001 From: peelz Date: Thu, 3 Jul 2025 16:35:18 -0400 Subject: [PATCH 10/21] fix(network): initialize all fields Some fields were previously uninitialized (e.g. carrier), which could lead to UB. --- include/modules/network.hpp | 44 ++++++++++++++++++------------------- src/modules/network.cpp | 20 +---------------- 2 files changed, 23 insertions(+), 41 deletions(-) diff --git a/include/modules/network.hpp b/include/modules/network.hpp index 5fd0c180..8e80d5aa 100644 --- a/include/modules/network.hpp +++ b/include/modules/network.hpp @@ -27,8 +27,8 @@ class Network : public ALabel { auto update() -> void override; private: - static const uint8_t MAX_RETRY = 5; - static const uint8_t EPOLL_MAX = 200; + static const uint8_t MAX_RETRY{5}; + static const uint8_t EPOLL_MAX{200}; static int handleEvents(struct nl_msg*, void*); static int handleEventsDone(struct nl_msg*, void*); @@ -51,37 +51,37 @@ class Network : public ALabel { bool wildcardMatch(const std::string& pattern, const std::string& text) const; std::optional> readBandwidthUsage(); - int ifid_; - ip_addr_pref addr_pref_; - struct sockaddr_nl nladdr_ = {0}; - struct nl_sock* sock_ = nullptr; - struct nl_sock* ev_sock_ = nullptr; - int efd_; - int ev_fd_; - int nl80211_id_; + int ifid_{-1}; + ip_addr_pref addr_pref_{ip_addr_pref::IPV4}; + struct sockaddr_nl nladdr_{0}; + struct nl_sock* sock_{nullptr}; + struct nl_sock* ev_sock_{nullptr}; + int efd_{-1}; + int ev_fd_{-1}; + int nl80211_id_{-1}; std::mutex mutex_; - bool want_route_dump_; - bool want_link_dump_; - bool want_addr_dump_; - bool dump_in_progress_; - bool is_p2p_; + bool want_route_dump_{false}; + bool want_link_dump_{false}; + bool want_addr_dump_{false}; + bool dump_in_progress_{false}; + bool is_p2p_{false}; - unsigned long long bandwidth_down_total_; - unsigned long long bandwidth_up_total_; + unsigned long long bandwidth_down_total_{0}; + unsigned long long bandwidth_up_total_{0}; std::string state_; std::string essid_; std::string bssid_; - bool carrier_; + bool carrier_{false}; std::string ifname_; std::string ipaddr_; std::string ipaddr6_; std::string gwaddr_; std::string netmask_; std::string netmask6_; - int cidr_; - int cidr6_; + int cidr_{0}; + int cidr6_{0}; int32_t signal_strength_dbm_; uint8_t signal_strength_; std::string signal_strength_app_; @@ -90,9 +90,9 @@ class Network : public ALabel { util::SleeperThread thread_; util::SleeperThread thread_timer_; #ifdef WANT_RFKILL - util::Rfkill rfkill_; + util::Rfkill rfkill_{RFKILL_TYPE_WLAN}; #endif - float frequency_; + float frequency_{0}; }; } // namespace waybar::modules diff --git a/src/modules/network.cpp b/src/modules/network.cpp index ca441bd5..35ba18fd 100644 --- a/src/modules/network.cpp +++ b/src/modules/network.cpp @@ -78,25 +78,7 @@ waybar::modules::Network::readBandwidthUsage() { } waybar::modules::Network::Network(const std::string &id, const Json::Value &config) - : ALabel(config, "network", id, DEFAULT_FORMAT, 60), - ifid_(-1), - addr_pref_(IPV4), - efd_(-1), - ev_fd_(-1), - want_route_dump_(false), - want_link_dump_(false), - want_addr_dump_(false), - dump_in_progress_(false), - is_p2p_(false), - cidr_(0), - cidr6_(0), - signal_strength_dbm_(0), - signal_strength_(0), -#ifdef WANT_RFKILL - rfkill_{RFKILL_TYPE_WLAN}, -#endif - frequency_(0.0) { - + : ALabel(config, "network", id, DEFAULT_FORMAT, 60) { // Start with some "text" in the module's label_. update() will then // update it. Since the text should be different, update() will be able // to show or hide the event_box_. This is to work around the case where From b85f0c17c39eb5f294b862bfe0c9d5ad08e1fd42 Mon Sep 17 00:00:00 2001 From: peelz Date: Thu, 3 Jul 2025 16:36:25 -0400 Subject: [PATCH 11/21] fix(network): ignore carrier state when the interface is down I'm not sure why, but my network card (mt7921e) sometimes will report having a carrier when the interface is down. This usually happens when rfkill was active before rebooting. --- src/modules/network.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/modules/network.cpp b/src/modules/network.cpp index 35ba18fd..9271aecb 100644 --- a/src/modules/network.cpp +++ b/src/modules/network.cpp @@ -494,6 +494,11 @@ int waybar::modules::Network::handleEvents(struct nl_msg *msg, void *data) { net->ifname_ = new_ifname; net->ifid_ = ifi->ifi_index; if (ifi->ifi_flags & IFF_POINTOPOINT) net->is_p2p_ = true; + if ((ifi->ifi_flags & IFF_UP) == 0) { + // With some network drivers (e.g. mt7921e), the interface may + // report having a carrier even though interface is down. + carrier = false; + } if (carrier.has_value()) { net->carrier_ = carrier.value(); } From 73d9c5f560e2b8b710402848faa1e1f99abe8841 Mon Sep 17 00:00:00 2001 From: peelz Date: Thu, 3 Jul 2025 16:46:43 -0400 Subject: [PATCH 12/21] fix(network): reset is_p2p_ in clearIface --- src/modules/network.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/modules/network.cpp b/src/modules/network.cpp index 9271aecb..94c77a69 100644 --- a/src/modules/network.cpp +++ b/src/modules/network.cpp @@ -405,6 +405,7 @@ void waybar::modules::Network::clearIface() { netmask_.clear(); netmask6_.clear(); carrier_ = false; + is_p2p_ = false; cidr_ = 0; cidr6_ = 0; signal_strength_dbm_ = 0; From 19360462bac545d372c84c43ca01555a4cb34489 Mon Sep 17 00:00:00 2001 From: Nick Raffaele Date: Sat, 12 Jul 2025 09:45:14 -0700 Subject: [PATCH 13/21] respect gtk color schema variant for gtk css variable --- src/client.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/client.cpp b/src/client.cpp index e363f236..946780db 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -151,15 +151,19 @@ void waybar::Client::handleDeferredMonitorRemoval(Glib::RefPtr mon const std::string waybar::Client::getStyle(const std::string &style, std::optional appearance = std::nullopt) { + auto gtk_settings = Gtk::Settings::get_default(); std::optional css_file; + if (style.empty()) { std::vector search_files; switch (appearance.value_or(portal->getAppearance())) { case waybar::Appearance::LIGHT: search_files.emplace_back("style-light.css"); + gtk_settings->property_gtk_application_prefer_dark_theme() = false; break; case waybar::Appearance::DARK: search_files.emplace_back("style-dark.css"); + gtk_settings->property_gtk_application_prefer_dark_theme() = true; break; case waybar::Appearance::UNKNOWN: break; @@ -169,9 +173,11 @@ const std::string waybar::Client::getStyle(const std::string &style, } else { css_file = style; } + if (!css_file) { throw std::runtime_error("Missing required resource files"); } + spdlog::info("Using CSS file {}", css_file.value()); return css_file.value(); }; From 061c5617628e14be4199add47880f7330e61c294 Mon Sep 17 00:00:00 2001 From: csskevin Date: Tue, 15 Jul 2025 00:19:55 +0200 Subject: [PATCH 14/21] adding dependency command for arch --- README.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/README.md b/README.md index 5266e916..4edf2253 100644 --- a/README.md +++ b/README.md @@ -116,6 +116,36 @@ sudo apt install \ libxkbregistry-dev ``` +On Arch, you can use this command: + +``` +pacman -S \ + gtkmm3 \ + jsoncpp \ + libsigc++ \ + fmt \ + wayland \ + chrono-date \ + spdlog \ + gtk3 \ + gobject-introspection \ + libgirepository \ + libpulse \ + libnl \ + libappindicator-gtk3 \ + libdbusmenu-gtk3 \ + libmpdclient \ + sndio \ + libevdev \ + libxkbcommon \ + upower \ + meson \ + cmake \ + scdoc \ + wayland-protocols \ + glib2-devel +``` + Contributions welcome!
Have fun :)
From e45883088d5d75515632729157231fdd8ac0e4a5 Mon Sep 17 00:00:00 2001 From: arnaud-ma Date: Sat, 19 Jul 2025 03:18:48 +0200 Subject: [PATCH 15/21] hyprland: Remove redundant workspace rules loading --- include/modules/hyprland/workspaces.hpp | 1 - src/modules/hyprland/workspaces.cpp | 48 +++++-------------------- 2 files changed, 9 insertions(+), 40 deletions(-) diff --git a/include/modules/hyprland/workspaces.hpp b/include/modules/hyprland/workspaces.hpp index 9a44e594..4f9eda47 100644 --- a/include/modules/hyprland/workspaces.hpp +++ b/include/modules/hyprland/workspaces.hpp @@ -118,7 +118,6 @@ class Workspaces : public AModule, public EventHandler { void initializeWorkspaces(); void setCurrentMonitorId(); void loadPersistentWorkspacesFromConfig(Json::Value const& clientsJson); - void loadPersistentWorkspacesFromWorkspaceRules(const Json::Value& clientsJson); bool m_allOutputs = false; bool m_showSpecial = false; diff --git a/src/modules/hyprland/workspaces.cpp b/src/modules/hyprland/workspaces.cpp index 06a6ed3c..739f0a9d 100644 --- a/src/modules/hyprland/workspaces.cpp +++ b/src/modules/hyprland/workspaces.cpp @@ -71,12 +71,12 @@ void Workspaces::createWorkspace(Json::Value const &workspace_data, // avoid recreating existing workspaces auto workspace = std::ranges::find_if(m_workspaces, [&](std::unique_ptr const &w) { - if (workspaceId > 0) { - return w->id() == workspaceId; - } - return (workspaceName.starts_with("special:") && workspaceName.substr(8) == w->name()) || - workspaceName == w->name(); - }); + if (workspaceId > 0) { + return w->id() == workspaceId; + } + return (workspaceName.starts_with("special:") && workspaceName.substr(8) == w->name()) || + workspaceName == w->name(); + }); if (workspace != m_workspaces.end()) { // don't recreate workspace, but update persistency if necessary @@ -206,8 +206,9 @@ void Workspaces::initializeWorkspaces() { // a persistent workspace config is defined, so use that instead of workspace rules loadPersistentWorkspacesFromConfig(clientsJson); } - // load Hyprland's workspace rules - loadPersistentWorkspacesFromWorkspaceRules(clientsJson); + // persistent workspaces configured with hyprland's workspace rules + // are already listed in 'workspacesJson', so we don't need to + // load them again. } bool isDoubleSpecial(std::string const &workspace_name) { @@ -282,37 +283,6 @@ void Workspaces::loadPersistentWorkspacesFromConfig(Json::Value const &clientsJs } } -void Workspaces::loadPersistentWorkspacesFromWorkspaceRules(const Json::Value &clientsJson) { - spdlog::info("Loading persistent workspaces from Hyprland workspace rules"); - - auto const workspaceRules = m_ipc.getSocket1JsonReply("workspacerules"); - for (Json::Value const &rule : workspaceRules) { - if (!rule["workspaceString"].isString()) { - spdlog::warn("Workspace rules: invalid workspaceString, skipping: {}", rule); - continue; - } - if (!rule["persistent"].asBool()) { - continue; - } - auto const &workspace = rule.isMember("defaultName") ? rule["defaultName"].asString() - : rule["workspaceString"].asString(); - auto const &monitor = rule["monitor"].asString(); - // create this workspace persistently if: - // 1. the allOutputs config option is enabled - // 2. the rule's monitor is the current monitor - // 3. no monitor is specified in the rule => assume it needs to be persistent on every monitor - if (allOutputs() || m_bar.output->name == monitor || monitor.empty()) { - // => persistent workspace should be shown on this monitor - auto workspaceData = createMonitorWorkspaceData(workspace, m_bar.output->name); - workspaceData["persistent-rule"] = true; - m_workspacesToCreate.emplace_back(workspaceData, clientsJson); - } else { - // This can be any workspace selector. - m_workspacesToRemove.emplace_back(workspace); - } - } -} - void Workspaces::onEvent(const std::string &ev) { std::lock_guard lock(m_mutex); std::string eventName(begin(ev), begin(ev) + ev.find_first_of('>')); From 64ed2cd97015f7c8ea6aad39838e36fe35acfcfd Mon Sep 17 00:00:00 2001 From: arnaud-ma Date: Sat, 19 Jul 2025 03:23:32 +0200 Subject: [PATCH 16/21] fix indentation --- src/modules/hyprland/workspaces.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/modules/hyprland/workspaces.cpp b/src/modules/hyprland/workspaces.cpp index 739f0a9d..19768c59 100644 --- a/src/modules/hyprland/workspaces.cpp +++ b/src/modules/hyprland/workspaces.cpp @@ -71,12 +71,12 @@ void Workspaces::createWorkspace(Json::Value const &workspace_data, // avoid recreating existing workspaces auto workspace = std::ranges::find_if(m_workspaces, [&](std::unique_ptr const &w) { - if (workspaceId > 0) { - return w->id() == workspaceId; - } - return (workspaceName.starts_with("special:") && workspaceName.substr(8) == w->name()) || - workspaceName == w->name(); - }); + if (workspaceId > 0) { + return w->id() == workspaceId; + } + return (workspaceName.starts_with("special:") && workspaceName.substr(8) == w->name()) || + workspaceName == w->name(); + }); if (workspace != m_workspaces.end()) { // don't recreate workspace, but update persistency if necessary From a4f200cdb5e470ef789124fa40461fb5b42cc260 Mon Sep 17 00:00:00 2001 From: arnaud-ma Date: Sat, 19 Jul 2025 04:47:31 +0200 Subject: [PATCH 17/21] revert --- include/modules/hyprland/workspaces.hpp | 2 +- src/modules/hyprland/workspaces.cpp | 53 +++++++++++++++++++------ 2 files changed, 42 insertions(+), 13 deletions(-) diff --git a/include/modules/hyprland/workspaces.hpp b/include/modules/hyprland/workspaces.hpp index 4f9eda47..cd3ccca5 100644 --- a/include/modules/hyprland/workspaces.hpp +++ b/include/modules/hyprland/workspaces.hpp @@ -118,7 +118,7 @@ class Workspaces : public AModule, public EventHandler { void initializeWorkspaces(); void setCurrentMonitorId(); void loadPersistentWorkspacesFromConfig(Json::Value const& clientsJson); - + void loadPersistentWorkspacesFromWorkspaceRules(const Json::Value& clientsJson); bool m_allOutputs = false; bool m_showSpecial = false; bool m_activeOnly = false; diff --git a/src/modules/hyprland/workspaces.cpp b/src/modules/hyprland/workspaces.cpp index 19768c59..cb422d35 100644 --- a/src/modules/hyprland/workspaces.cpp +++ b/src/modules/hyprland/workspaces.cpp @@ -69,14 +69,13 @@ void Workspaces::createWorkspace(Json::Value const &workspace_data, spdlog::debug("Creating workspace {}", workspaceName); // avoid recreating existing workspaces - auto workspace = - std::ranges::find_if(m_workspaces, [&](std::unique_ptr const &w) { - if (workspaceId > 0) { - return w->id() == workspaceId; - } - return (workspaceName.starts_with("special:") && workspaceName.substr(8) == w->name()) || - workspaceName == w->name(); - }); + auto workspace = std::ranges::find_if(m_workspaces, [&](std::unique_ptr const &w) { + if (workspaceId > 0) { + return w->id() == workspaceId; + } + return (workspaceName.starts_with("special:") && workspaceName.substr(8) == w->name()) || + workspaceName == w->name(); + }); if (workspace != m_workspaces.end()) { // don't recreate workspace, but update persistency if necessary @@ -206,9 +205,8 @@ void Workspaces::initializeWorkspaces() { // a persistent workspace config is defined, so use that instead of workspace rules loadPersistentWorkspacesFromConfig(clientsJson); } - // persistent workspaces configured with hyprland's workspace rules - // are already listed in 'workspacesJson', so we don't need to - // load them again. + // load Hyprland's workspace rules + loadPersistentWorkspacesFromWorkspaceRules(clientsJson); } bool isDoubleSpecial(std::string const &workspace_name) { @@ -283,6 +281,37 @@ void Workspaces::loadPersistentWorkspacesFromConfig(Json::Value const &clientsJs } } +void Workspaces::loadPersistentWorkspacesFromWorkspaceRules(const Json::Value &clientsJson) { + spdlog::info("Loading persistent workspaces from Hyprland workspace rules"); + + auto const workspaceRules = m_ipc.getSocket1JsonReply("workspacerules"); + for (Json::Value const &rule : workspaceRules) { + if (!rule["workspaceString"].isString()) { + spdlog::warn("Workspace rules: invalid workspaceString, skipping: {}", rule); + continue; + } + if (!rule["persistent"].asBool()) { + continue; + } + auto const &workspace = rule.isMember("defaultName") ? rule["defaultName"].asString() + : rule["workspaceString"].asString(); + auto const &monitor = rule["monitor"].asString(); + // create this workspace persistently if: + // 1. the allOutputs config option is enabled + // 2. the rule's monitor is the current monitor + // 3. no monitor is specified in the rule => assume it needs to be persistent on every monitor + if (allOutputs() || m_bar.output->name == monitor || monitor.empty()) { + // => persistent workspace should be shown on this monitor + auto workspaceData = createMonitorWorkspaceData(workspace, m_bar.output->name); + workspaceData["persistent-rule"] = true; + m_workspacesToCreate.emplace_back(workspaceData, clientsJson); + } else { + // This can be any workspace selector. + m_workspacesToRemove.emplace_back(workspace); + } + } +} + void Workspaces::onEvent(const std::string &ev) { std::lock_guard lock(m_mutex); std::string eventName(begin(ev), begin(ev) + ev.find_first_of('>')); @@ -1004,4 +1033,4 @@ std::optional Workspaces::parseWorkspaceId(std::string const &workspaceIdSt } } -} // namespace waybar::modules::hyprland +} // namespace waybar::modules::hyprland \ No newline at end of file From 2dc2b5ccfd368a3cd2fb27d2d1ece05bf0582441 Mon Sep 17 00:00:00 2001 From: arnaud-ma Date: Sat, 19 Jul 2025 04:50:59 +0200 Subject: [PATCH 18/21] fix #4307 --- src/modules/hyprland/workspaces.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/modules/hyprland/workspaces.cpp b/src/modules/hyprland/workspaces.cpp index cb422d35..79838ffc 100644 --- a/src/modules/hyprland/workspaces.cpp +++ b/src/modules/hyprland/workspaces.cpp @@ -293,8 +293,11 @@ void Workspaces::loadPersistentWorkspacesFromWorkspaceRules(const Json::Value &c if (!rule["persistent"].asBool()) { continue; } - auto const &workspace = rule.isMember("defaultName") ? rule["defaultName"].asString() + auto workspace = rule.isMember("defaultName") ? rule["defaultName"].asString() : rule["workspaceString"].asString(); + if (workspace.starts_with("name:")) { + workspace = workspace.substr(5); + } auto const &monitor = rule["monitor"].asString(); // create this workspace persistently if: // 1. the allOutputs config option is enabled From 8dcdd97879f4fe84c97d0ac5a12c4f89c4d98606 Mon Sep 17 00:00:00 2001 From: arnaud-ma Date: Sat, 19 Jul 2025 05:01:29 +0200 Subject: [PATCH 19/21] small fixes --- include/modules/hyprland/workspaces.hpp | 1 + src/modules/hyprland/workspaces.cpp | 17 ++++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/include/modules/hyprland/workspaces.hpp b/include/modules/hyprland/workspaces.hpp index cd3ccca5..9a44e594 100644 --- a/include/modules/hyprland/workspaces.hpp +++ b/include/modules/hyprland/workspaces.hpp @@ -119,6 +119,7 @@ class Workspaces : public AModule, public EventHandler { void setCurrentMonitorId(); void loadPersistentWorkspacesFromConfig(Json::Value const& clientsJson); void loadPersistentWorkspacesFromWorkspaceRules(const Json::Value& clientsJson); + bool m_allOutputs = false; bool m_showSpecial = false; bool m_activeOnly = false; diff --git a/src/modules/hyprland/workspaces.cpp b/src/modules/hyprland/workspaces.cpp index 79838ffc..b6f1fbc0 100644 --- a/src/modules/hyprland/workspaces.cpp +++ b/src/modules/hyprland/workspaces.cpp @@ -69,13 +69,14 @@ void Workspaces::createWorkspace(Json::Value const &workspace_data, spdlog::debug("Creating workspace {}", workspaceName); // avoid recreating existing workspaces - auto workspace = std::ranges::find_if(m_workspaces, [&](std::unique_ptr const &w) { - if (workspaceId > 0) { - return w->id() == workspaceId; - } - return (workspaceName.starts_with("special:") && workspaceName.substr(8) == w->name()) || - workspaceName == w->name(); - }); + auto workspace = + std::ranges::find_if(m_workspaces, [&](std::unique_ptr const &w) { + if (workspaceId > 0) { + return w->id() == workspaceId; + } + return (workspaceName.starts_with("special:") && workspaceName.substr(8) == w->name()) || + workspaceName == w->name(); + }); if (workspace != m_workspaces.end()) { // don't recreate workspace, but update persistency if necessary @@ -295,6 +296,8 @@ void Workspaces::loadPersistentWorkspacesFromWorkspaceRules(const Json::Value &c } auto workspace = rule.isMember("defaultName") ? rule["defaultName"].asString() : rule["workspaceString"].asString(); + + // The prefix "name:" cause mismatches with workspace names taken anywhere else. if (workspace.starts_with("name:")) { workspace = workspace.substr(5); } From b4d95b405cba2700aa3c9d1c4e4110c51555c5c9 Mon Sep 17 00:00:00 2001 From: peelz Date: Sun, 20 Jul 2025 22:40:29 -0400 Subject: [PATCH 20/21] style: clang-format --- src/modules/hyprland/workspaces.cpp | 17 ++++++++--------- src/modules/sni/item.cpp | 1 - 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/modules/hyprland/workspaces.cpp b/src/modules/hyprland/workspaces.cpp index b6f1fbc0..cfc62025 100644 --- a/src/modules/hyprland/workspaces.cpp +++ b/src/modules/hyprland/workspaces.cpp @@ -69,14 +69,13 @@ void Workspaces::createWorkspace(Json::Value const &workspace_data, spdlog::debug("Creating workspace {}", workspaceName); // avoid recreating existing workspaces - auto workspace = - std::ranges::find_if(m_workspaces, [&](std::unique_ptr const &w) { - if (workspaceId > 0) { - return w->id() == workspaceId; - } - return (workspaceName.starts_with("special:") && workspaceName.substr(8) == w->name()) || - workspaceName == w->name(); - }); + auto workspace = std::ranges::find_if(m_workspaces, [&](std::unique_ptr const &w) { + if (workspaceId > 0) { + return w->id() == workspaceId; + } + return (workspaceName.starts_with("special:") && workspaceName.substr(8) == w->name()) || + workspaceName == w->name(); + }); if (workspace != m_workspaces.end()) { // don't recreate workspace, but update persistency if necessary @@ -295,7 +294,7 @@ void Workspaces::loadPersistentWorkspacesFromWorkspaceRules(const Json::Value &c continue; } auto workspace = rule.isMember("defaultName") ? rule["defaultName"].asString() - : rule["workspaceString"].asString(); + : rule["workspaceString"].asString(); // The prefix "name:" cause mismatches with workspace names taken anywhere else. if (workspace.starts_with("name:")) { diff --git a/src/modules/sni/item.cpp b/src/modules/sni/item.cpp index 69417f62..4e80eba7 100644 --- a/src/modules/sni/item.cpp +++ b/src/modules/sni/item.cpp @@ -1,4 +1,3 @@ -#include #include "modules/sni/item.hpp" #include From bb190409deeef4a5885c8d190ff6059867c623cc Mon Sep 17 00:00:00 2001 From: Erik Alonso Date: Mon, 21 Jul 2025 19:04:37 +0100 Subject: [PATCH 21/21] fix: unable to disable upower's tooltip --- src/modules/upower.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/modules/upower.cpp b/src/modules/upower.cpp index 4b832b7e..4844582f 100644 --- a/src/modules/upower.cpp +++ b/src/modules/upower.cpp @@ -10,7 +10,6 @@ UPower::UPower(const std::string &id, const Json::Value &config) : AIconLabel(config, "upower", id, "{percentage}", 0, true, true, true), sleeping_{false} { box_.set_name(name_); box_.set_spacing(0); - box_.set_has_tooltip(AModule::tooltipEnabled()); // Tooltip box contentBox_.set_orientation((box_.get_orientation() == Gtk::ORIENTATION_HORIZONTAL) ? Gtk::ORIENTATION_VERTICAL @@ -70,8 +69,10 @@ UPower::UPower(const std::string &id, const Json::Value &config) g_signal_connect(upClient_, "device-removed", G_CALLBACK(deviceRemoved_cb), this); // Subscribe tooltip query events - box_.set_has_tooltip(); - box_.signal_query_tooltip().connect(sigc::mem_fun(*this, &UPower::queryTooltipCb), false); + box_.set_has_tooltip(AModule::tooltipEnabled()); + if (AModule::tooltipEnabled()) { + box_.signal_query_tooltip().connect(sigc::mem_fun(*this, &UPower::queryTooltipCb), false); + } resetDevices(); setDisplayDevice();