From 9cc86f52dc05182980b3533d07c4070a8ffc0f7d Mon Sep 17 00:00:00 2001 From: Vaxry Date: Fri, 9 Feb 2024 15:49:08 +0000 Subject: [PATCH] fix hyprctl getoption --- src/debug/HyprCtl.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/debug/HyprCtl.cpp b/src/debug/HyprCtl.cpp index a122fbe7..46bafcf4 100644 --- a/src/debug/HyprCtl.cpp +++ b/src/debug/HyprCtl.cpp @@ -14,6 +14,7 @@ #include #include +#include static void trimTrailingComma(std::string& str) { if (!str.empty() && str.back() == ',') @@ -1184,9 +1185,26 @@ std::string dispatchGetOption(eHyprCtlOutputFormat format, std::string request) nextItem(); nextItem(); - // HYPRLANG_TODO: + const auto VAR = g_pConfigManager->getHyprlangConfigValuePtr(curitem); - return ""; + if (!VAR) + return "no such option"; + + const auto VAL = VAR->getValue(); + const auto TYPE = std::type_index(VAL.type()); + + if (TYPE == typeid(Hyprlang::INT)) + return std::format("int: {}", std::any_cast(VAL)); + else if (TYPE == typeid(Hyprlang::FLOAT)) + return std::format("float: {:2f}", std::any_cast(VAL)); + else if (TYPE == typeid(Hyprlang::VEC2)) + return std::format("vec2: {}, {}", std::any_cast(VAL).x, std::any_cast(VAL).y); + else if (TYPE == typeid(Hyprlang::STRING)) + return std::format("str: {}", std::any_cast(VAL)); + else if (TYPE == typeid(Hyprlang::CUSTOMTYPE*)) + return std::format("custom type at: {:x}", (uintptr_t)std::any_cast(VAL)); + + return "invalid type (internal error)"; } std::string decorationRequest(eHyprCtlOutputFormat format, std::string request) {