diff --git a/include/modules/hyprland/workspace.hpp b/include/modules/hyprland/workspace.hpp index 48a027c3..71529363 100644 --- a/include/modules/hyprland/workspace.hpp +++ b/include/modules/hyprland/workspace.hpp @@ -63,7 +63,6 @@ class Workspace { std::optional closeWindow(WindowAddress const& addr); void update(const std::string& workspace_icon); - void updateTaskbar(const std::string& workspace_icon); private: Workspaces& m_workspaceManager; @@ -85,6 +84,8 @@ class Workspace { Gtk::Box m_content; Gtk::Label m_labelBefore; Gtk::Label m_labelAfter; + + void updateTaskbar(const std::string& workspace_icon); }; } // namespace waybar::modules::hyprland diff --git a/include/modules/hyprland/workspaces.hpp b/include/modules/hyprland/workspaces.hpp index d2842b73..75ac95dc 100644 --- a/include/modules/hyprland/workspaces.hpp +++ b/include/modules/hyprland/workspaces.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include @@ -46,6 +47,8 @@ class Workspaces : public AModule, public EventHandler { auto formatAfter() const -> std::string { return m_formatAfter; } auto taskbarFormatBefore() const -> std::string { return m_taskbarFormatBefore; } auto taskbarFormatAfter() const -> std::string { return m_taskbarFormatAfter; } + auto taskbarIconSize() const -> int { return m_taskbarIconSize; } + auto taskbarOrientation() const -> Gtk::Orientation { return m_taskbarOrientation; } std::string getRewrite(std::string window_class, std::string window_title); std::string& getWindowSeparator() { return m_formatWindowSeparator; } @@ -160,6 +163,8 @@ class Workspaces : public AModule, public EventHandler { bool m_taskbarWithIcon = false; std::string m_taskbarFormatBefore; std::string m_taskbarFormatAfter; + int m_taskbarIconSize = 16; + Gtk::Orientation m_taskbarOrientation = Gtk::ORIENTATION_HORIZONTAL; std::vector m_ignoreWorkspaces; diff --git a/include/util/string.hpp b/include/util/string.hpp index 2da2bcc5..cb8a6892 100644 --- a/include/util/string.hpp +++ b/include/util/string.hpp @@ -24,6 +24,13 @@ inline std::string capitalize(const std::string& str) { return result; } +inline std::string toLower(const std::string& str) { + std::string result = str; + std::transform(result.begin(), result.end(), result.begin(), + [](unsigned char c) { return std::tolower(c); }); + return result; +} + inline std::vector split(std::string_view s, std::string_view delimiter, int max_splits = -1) { std::vector result; diff --git a/src/modules/hyprland/workspace.cpp b/src/modules/hyprland/workspace.cpp index 140f4f77..aa12f33c 100644 --- a/src/modules/hyprland/workspace.cpp +++ b/src/modules/hyprland/workspace.cpp @@ -32,9 +32,8 @@ Workspace::Workspace(const Json::Value &workspace_data, Workspaces &workspace_ma false); m_button.set_relief(Gtk::RELIEF_NONE); - if (true) { - // TODO-WorkspaceTaskbar: Allow vertical? - m_content.set_orientation(Gtk::ORIENTATION_HORIZONTAL); + if (m_workspaceManager.enableWorkspaceTaskbar()) { + m_content.set_orientation(m_workspaceManager.taskbarOrientation()); m_content.pack_start(m_labelBefore, false, false); } else { m_content.set_center_widget(m_labelBefore); @@ -251,12 +250,10 @@ void Workspace::updateTaskbar(const std::string &workspace_icon) { } if (m_workspaceManager.taskbarWithIcon()) { - // TODO-WorkspaceTaskbar: support themes auto app_info_ = IconLoader::get_app_info_from_app_id_list(window_repr.window_class); - - // TODO-WorkspaceTaskbar: icon size + int icon_size = m_workspaceManager.taskbarIconSize(); auto window_icon = Gtk::make_managed(); - m_workspaceManager.iconLoader().image_load_icon(*window_icon, app_info_, 24); + m_workspaceManager.iconLoader().image_load_icon(*window_icon, app_info_, icon_size); window_box->pack_start(*window_icon, false, false); } diff --git a/src/modules/hyprland/workspaces.cpp b/src/modules/hyprland/workspaces.cpp index 917999b7..ebc4c17c 100644 --- a/src/modules/hyprland/workspaces.cpp +++ b/src/modules/hyprland/workspaces.cpp @@ -685,6 +685,23 @@ auto Workspaces::populateWorkspaceTaskbarConfig(const Json::Value &config) -> vo /* The default is to only show the icon */ m_taskbarWithIcon = true; } + + auto iconTheme = workspaceTaskbar["icon-theme"]; + if (iconTheme.isArray()) { + for (auto &c : iconTheme) { + m_iconLoader.add_custom_icon_theme(c.asString()); + } + } else if (iconTheme.isString()) { + m_iconLoader.add_custom_icon_theme(iconTheme.asString()); + } + + if (workspaceTaskbar["icon-size"].isInt()) { + m_taskbarIconSize = workspaceTaskbar["icon-size"].asInt(); + } + if (workspaceTaskbar["orientation"].isString() && + toLower(workspaceTaskbar["orientation"].asString()) == "vertical") { + m_taskbarOrientation = Gtk::ORIENTATION_VERTICAL; + } } void Workspaces::registerOrphanWindow(WindowCreationPayload create_window_payload) {