diff --git a/include/modules/hyprland/workspaces.hpp b/include/modules/hyprland/workspaces.hpp index 42791e48..1a8fe872 100644 --- a/include/modules/hyprland/workspaces.hpp +++ b/include/modules/hyprland/workspaces.hpp @@ -94,7 +94,7 @@ class Workspace { bool onWindowOpened(WindowCreationPayload const& create_window_paylod); std::optional closeWindow(WindowAddress const& addr); - void update(const std::string& format, const std::string& icon); + void update(const std::string& format, const std::string& icon, const std::string &tooltipFormat); private: Workspaces& m_workspaceManager; @@ -199,6 +199,7 @@ class Workspaces : public AModule, public EventHandler { {"DEFAULT", SortMethod::DEFAULT}}; std::string m_format; + std::string m_tooltipFormat; std::map m_iconsMap; util::RegexCollection m_windowRewriteRules; diff --git a/src/modules/hyprland/workspaces.cpp b/src/modules/hyprland/workspaces.cpp index 9e368306..1bfe6a7c 100644 --- a/src/modules/hyprland/workspaces.cpp +++ b/src/modules/hyprland/workspaces.cpp @@ -60,6 +60,13 @@ auto Workspaces::parseConfig(const Json::Value &config) -> void { m_format = configFormat.isString() ? configFormat.asString() : "{name}"; m_withIcon = m_format.find("{icon}") != std::string::npos; + if (tooltipEnabled()) { + const Json::Value &configTooltipFormat = config["tooltip-format"]; + m_tooltipFormat = configTooltipFormat.isString() ? configTooltipFormat.asString() : "{name}"; + } else { + m_tooltipFormat = ""; + } + if (m_withIcon && m_iconsMap.empty()) { Json::Value formatIcons = config["format-icons"]; for (std::string &name : formatIcons.getMemberNames()) { @@ -237,7 +244,7 @@ void Workspaces::doUpdate() { }); workspace->setOutput((*updated_workspace)["monitor"].asString()); - workspace->update(m_format, workspaceIcon); + workspace->update(m_format, workspaceIcon, m_tooltipFormat); } spdlog::trace("Updating window count"); @@ -866,7 +873,7 @@ void addOrRemoveClass(const Glib::RefPtr &context, bool condi } } -void Workspace::update(const std::string &format, const std::string &icon) { +void Workspace::update(const std::string &format, const std::string &icon, const std::string &tooltipFormat) { // clang-format off if (this->m_workspaceManager.activeOnly() && \ !this->isActive() && \ @@ -902,6 +909,10 @@ void Workspace::update(const std::string &format, const std::string &icon) { windows.append(window_repr); } + m_button.set_tooltip_text(fmt::format(fmt::runtime(tooltipFormat), fmt::arg("id", id()), + fmt::arg("name", name()), fmt::arg("icon", icon), + fmt::arg("windows", windows))); + m_label.set_markup(fmt::format(fmt::runtime(format), fmt::arg("id", id()), fmt::arg("name", name()), fmt::arg("icon", icon), fmt::arg("windows", windows)));