MCPcopy Create free account
hub / github.com/Alexays/Waybar / populateWorkspaceTaskbarConfig

Method populateWorkspaceTaskbarConfig

src/modules/hyprland/workspaces.cpp:726–795  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

724}
725
726auto Workspaces::populateWorkspaceTaskbarConfig(const Json::Value& config) -> void {
727 const auto& workspaceTaskbar = config["workspace-taskbar"];
728 if (!workspaceTaskbar.isObject()) {
729 spdlog::debug("workspace-taskbar is not defined or is not an object, using default rules.");
730 return;
731 }
732
733 populateBoolConfig(workspaceTaskbar, "enable", m_enableTaskbar);
734 populateBoolConfig(workspaceTaskbar, "update-active-window", m_updateActiveWindow);
735 populateBoolConfig(workspaceTaskbar, "reverse-direction", m_taskbarReverseDirection);
736
737 if (workspaceTaskbar["format"].isString()) {
738 /* The user defined a format string, use it */
739 std::string format = workspaceTaskbar["format"].asString();
740 m_taskbarWithTitle = format.find("{title") != std::string::npos; /* {title} or {title.length} */
741 auto parts = split(format, "{icon}", 1);
742 m_taskbarFormatBefore = parts[0];
743 if (parts.size() > 1) {
744 m_taskbarWithIcon = true;
745 m_taskbarFormatAfter = parts[1];
746 }
747 } else {
748 /* The default is to only show the icon */
749 m_taskbarWithIcon = true;
750 }
751
752 auto iconTheme = workspaceTaskbar["icon-theme"];
753 if (iconTheme.isArray()) {
754 for (auto& c : iconTheme) {
755 m_iconLoader.add_custom_icon_theme(c.asString());
756 }
757 } else if (iconTheme.isString()) {
758 m_iconLoader.add_custom_icon_theme(iconTheme.asString());
759 }
760
761 if (workspaceTaskbar["icon-size"].isInt()) {
762 m_taskbarIconSize = workspaceTaskbar["icon-size"].asInt();
763 }
764 if (workspaceTaskbar["orientation"].isString() &&
765 toLower(workspaceTaskbar["orientation"].asString()) == "vertical") {
766 m_taskbarOrientation = Gtk::ORIENTATION_VERTICAL;
767 }
768
769 if (workspaceTaskbar["on-click-window"].isString()) {
770 m_onClickWindow = workspaceTaskbar["on-click-window"].asString();
771 }
772
773 if (workspaceTaskbar["ignore-list"].isArray()) {
774 for (auto& windowRegex : workspaceTaskbar["ignore-list"]) {
775 std::string ruleString = windowRegex.asString();
776 try {
777 m_ignoreWindows.emplace_back(ruleString, std::regex_constants::icase);
778 } catch (const std::regex_error& e) {
779 spdlog::error("Invalid rule {}: {}", ruleString, e.what());
780 }
781 }
782 }
783

Callers

nothing calls this directly

Calls 4

splitFunction · 0.85
toLowerFunction · 0.85
add_custom_icon_themeMethod · 0.80
parseStringToEnumMethod · 0.80

Tested by

no test coverage detected