From 6a92473237f430399a417e1c2da9d7fcd4970086 Mon Sep 17 00:00:00 2001 From: Vaxry Date: Thu, 21 Mar 2024 15:42:18 +0000 Subject: [PATCH] lib: accept theme names for lookup --- libhyprcursor/hyprcursor.cpp | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/libhyprcursor/hyprcursor.cpp b/libhyprcursor/hyprcursor.cpp index 5de9daf..73e023e 100644 --- a/libhyprcursor/hyprcursor.cpp +++ b/libhyprcursor/hyprcursor.cpp @@ -99,13 +99,31 @@ static std::string getFullPathForThemeName(const std::string& name) { if (!themeDir.is_directory()) continue; - if (!name.empty() && themeDir.path().stem().string() != name) - continue; - const auto MANIFESTPATH = themeDir.path().string() + "/manifest.hl"; - if (std::filesystem::exists(MANIFESTPATH)) - return std::filesystem::canonical(themeDir.path()).string(); + if (name.empty()) { + if (std::filesystem::exists(MANIFESTPATH)) + return std::filesystem::canonical(themeDir.path()).string(); + continue; + } + + if (!std::filesystem::exists(MANIFESTPATH)) + continue; + + std::unique_ptr manifest; + try { + manifest = std::make_unique(MANIFESTPATH.c_str(), Hyprlang::SConfigOptions{}); + manifest->addConfigValue("name", Hyprlang::STRING{""}); + manifest->commence(); + manifest->parse(); + } catch (const char* e) { continue; } + + const std::string NAME = std::any_cast(manifest->getConfigValue("name")); + + if (NAME != name) + continue; + + return std::filesystem::canonical(themeDir.path()).string(); } }