diff options
author | Vaxry <[email protected]> | 2024-02-09 15:49:08 +0000 |
---|---|---|
committer | Vaxry <[email protected]> | 2024-02-09 15:49:08 +0000 |
commit | 9cc86f52dc05182980b3533d07c4070a8ffc0f7d (patch) | |
tree | c165a4d7e1d6600adf483ef3a12dda05fb579eda | |
parent | fdf8da10122172c23389cd748563e468314e528f (diff) | |
download | Hyprland-9cc86f52dc05182980b3533d07c4070a8ffc0f7d.tar.gz Hyprland-9cc86f52dc05182980b3533d07c4070a8ffc0f7d.zip |
fix hyprctl getoption
-rw-r--r-- | src/debug/HyprCtl.cpp | 22 |
1 files 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 <sstream> #include <string> +#include <typeindex> 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<Hyprlang::INT>(VAL)); + else if (TYPE == typeid(Hyprlang::FLOAT)) + return std::format("float: {:2f}", std::any_cast<Hyprlang::FLOAT>(VAL)); + else if (TYPE == typeid(Hyprlang::VEC2)) + return std::format("vec2: {}, {}", std::any_cast<Hyprlang::VEC2>(VAL).x, std::any_cast<Hyprlang::VEC2>(VAL).y); + else if (TYPE == typeid(Hyprlang::STRING)) + return std::format("str: {}", std::any_cast<Hyprlang::STRING>(VAL)); + else if (TYPE == typeid(Hyprlang::CUSTOMTYPE*)) + return std::format("custom type at: {:x}", (uintptr_t)std::any_cast<Hyprlang::CUSTOMTYPE*>(VAL)); + + return "invalid type (internal error)"; } std::string decorationRequest(eHyprCtlOutputFormat format, std::string request) { |