diff options
Diffstat (limited to 'src/debug/HyprCtl.cpp')
| -rw-r--r-- | src/debug/HyprCtl.cpp | 230 |
1 files changed, 10 insertions, 220 deletions
diff --git a/src/debug/HyprCtl.cpp b/src/debug/HyprCtl.cpp index 11171472..278e92c6 100644 --- a/src/debug/HyprCtl.cpp +++ b/src/debug/HyprCtl.cpp @@ -49,9 +49,10 @@ using namespace Hyprutils::OS; #include "../devices/ITouch.hpp" #include "../devices/Tablet.hpp" #include "../protocols/GlobalShortcuts.hpp" -#include "debug/log/RollingLogFollow.hpp" -#include "config/ConfigManager.hpp" -#include "helpers/MiscFunctions.hpp" +#include "../debug/log/RollingLogFollow.hpp" +#include "../config/ConfigManager.hpp" +#include "../helpers/MiscFunctions.hpp" +#include "../helpers/SystemInfo.hpp" #include "../desktop/view/LayerSurface.hpp" #include "../desktop/view/Group.hpp" #include "../desktop/rule/Engine.hpp" @@ -1061,193 +1062,19 @@ static std::string bindsRequest(eHyprCtlOutputFormat format, std::string request } std::string versionRequest(eHyprCtlOutputFormat format, std::string request) { + return Helpers::SystemInfo::getVersion(format); +} - auto commitMsg = trim(GIT_COMMIT_MESSAGE); - std::ranges::replace(commitMsg, '#', ' '); - - if (format == eHyprCtlOutputFormat::FORMAT_NORMAL) { - std::string result = std::format("Hyprland {} built from branch {} at commit {} {} ({}).\n" - "Date: {}\n" - "Tag: {}, commits: {}\n", - HYPRLAND_VERSION, GIT_BRANCH, GIT_COMMIT_HASH, GIT_DIRTY, commitMsg, GIT_COMMIT_DATE, GIT_TAG, GIT_COMMITS); - - result += "\n"; - result += getBuiltSystemLibraryNames(); - result += "\n"; - result += "Version ABI string: "; - result += __hyprland_api_get_hash(); - result += "\n"; - -#if (!ISDEBUG && !defined(NO_XWAYLAND) && !defined(BUILT_WITH_NIX)) - result += "no flags were set\n"; -#else - result += "flags set:\n"; -#if ISDEBUG - result += "debug\n"; -#endif -#ifdef NO_XWAYLAND - result += "no xwayland\n"; -#endif -#ifdef BUILT_WITH_NIX - result += "nix\n"; -#endif -#endif - return result; - } else { - std::string result = std::format( - R"#({{ - "branch": "{}", - "commit": "{}", - "version": "{}", - "dirty": {}, - "commit_message": "{}", - "commit_date": "{}", - "tag": "{}", - "commits": "{}", - "buildAquamarine": "{}", - "buildHyprlang": "{}", - "buildHyprutils": "{}", - "buildHyprcursor": "{}", - "buildHyprgraphics": "{}", - "systemAquamarine": "{}", - "systemHyprlang": "{}", - "systemHyprutils": "{}", - "systemHyprcursor": "{}", - "systemHyprgraphics": "{}", - "abiHash": "{}", - "flags": [)#", - GIT_BRANCH, GIT_COMMIT_HASH, HYPRLAND_VERSION, (strcmp(GIT_DIRTY, "dirty") == 0 ? "true" : "false"), escapeJSONStrings(commitMsg), GIT_COMMIT_DATE, GIT_TAG, - GIT_COMMITS, AQUAMARINE_VERSION, HYPRLANG_VERSION, HYPRUTILS_VERSION, HYPRCURSOR_VERSION, HYPRGRAPHICS_VERSION, getSystemLibraryVersion("aquamarine"), - getSystemLibraryVersion("hyprlang"), getSystemLibraryVersion("hyprutils"), getSystemLibraryVersion("hyprcursor"), getSystemLibraryVersion("hyprgraphics"), - __hyprland_api_get_hash()); - -#if ISDEBUG - result += "\"debug\","; -#endif -#ifdef NO_XWAYLAND - result += "\"no xwayland\","; -#endif -#ifdef BUILT_WITH_NIX - result += "\"nix\","; -#endif - - trimTrailingComma(result); - - result += "]\n}"; - - return result; - } - - return ""; // make the compiler happy +static std::string statusRequest(eHyprCtlOutputFormat format, std::string request) { + return Helpers::SystemInfo::getStatus(format); } std::string systemInfoRequest(eHyprCtlOutputFormat format, std::string request) { - std::string result = versionRequest(eHyprCtlOutputFormat::FORMAT_NORMAL, ""); - - static auto check = [](bool y) -> std::string { return y ? "✔️" : "❌"; }; - static auto backend = [](Aquamarine::eBackendType t) -> std::string { - switch (t) { - case Aquamarine::AQ_BACKEND_DRM: return "drm"; - case Aquamarine::AQ_BACKEND_HEADLESS: return "headless"; - case Aquamarine::AQ_BACKEND_WAYLAND: return "wayland"; - default: break; - } - return "?"; - }; - - result += "\n\nSystem Information:\n"; - - struct utsname unameInfo; - uname(&unameInfo); - - result += "System name: " + std::string{unameInfo.sysname} + "\n"; - result += "Node name: " + std::string{unameInfo.nodename} + "\n"; - result += "Release: " + std::string{unameInfo.release} + "\n"; - result += "Version: " + std::string{unameInfo.version} + "\n"; - result += "\n"; - result += getBuiltSystemLibraryNames(); - result += "\n"; - - result += "\n\n"; - -#if defined(__DragonFly__) || defined(__FreeBSD__) - const std::string GPUINFO = execAndGet("pciconf -lv | grep -F -A4 vga"); -#elif defined(__arm__) || defined(__aarch64__) - std::string GPUINFO; - const std::filesystem::path dev_tree = "/proc/device-tree"; - try { - if (std::filesystem::exists(dev_tree) && std::filesystem::is_directory(dev_tree)) { - std::for_each(std::filesystem::directory_iterator(dev_tree), std::filesystem::directory_iterator{}, [&](const std::filesystem::directory_entry& entry) { - if (std::filesystem::is_directory(entry) && entry.path().filename().string().starts_with("soc")) { - std::for_each(std::filesystem::directory_iterator(entry.path()), std::filesystem::directory_iterator{}, [&](const std::filesystem::directory_entry& sub_entry) { - if (std::filesystem::is_directory(sub_entry) && sub_entry.path().filename().string().starts_with("gpu")) { - std::filesystem::path file_path = sub_entry.path() / "compatible"; - std::ifstream file(file_path); - if (file) - GPUINFO.append(std::istreambuf_iterator<char>(file), std::istreambuf_iterator<char>()); - } - }); - } - }); - } - } catch (...) { GPUINFO = "error"; } -#else - const std::string GPUINFO = execAndGet("lspci -vnn | grep -E '(VGA|Display|3D)'"); -#endif - result += "GPU information: \n" + GPUINFO; - if (GPUINFO.contains("NVIDIA") && std::filesystem::exists("/proc/driver/nvidia/version")) { - std::ifstream file("/proc/driver/nvidia/version"); - std::string line; - if (file.is_open()) { - while (std::getline(file, line)) { - if (!line.contains("NVRM")) - continue; - result += line; - result += "\n"; - } - } else - result += "error"; - } - result += "\n\n"; - - if (std::ifstream file("/etc/os-release"); file.is_open()) { - std::stringstream buffer; - buffer << file.rdbuf(); - result += "os-release: " + buffer.str() + "\n\n"; - } else - result += "os-release: error\n\n"; - - result += "plugins:\n"; - if (g_pPluginSystem) { - for (auto const& pl : g_pPluginSystem->getAllPlugins()) { - result += std::format(" {} by {} ver {}\n", pl->m_name, pl->m_author, pl->m_version); - } - } else - result += "\tunknown: not runtime\n"; - - if (g_pHyprOpenGL) { - result += std::format("\nExplicit sync: {}", g_pHyprOpenGL->m_exts.EGL_ANDROID_native_fence_sync_ext ? "supported" : "missing"); - result += std::format("\nGL ver: {}", g_pHyprOpenGL->m_eglContextVersion == CHyprOpenGLImpl::EGL_CONTEXT_GLES_3_2 ? "3.2" : "3.0"); - } - - if (g_pCompositor) { - result += std::format("\nBackend: {}", g_pCompositor->m_aqBackend->hasSession() ? "drm" : "sessionless"); - - result += "\n\nMonitor info:"; - - for (const auto& m : g_pCompositor->m_monitors) { - result += std::format("\n\tPanel {}: {}x{}, {} {} {} {} -> backend {}\n\t\texplicit {}\n\t\tedid:\n\t\t\thdr {}\n\t\t\tchroma {}\n\t\t\tbt2020 {}\n\t\tvrr capable " - "{}\n\t\tnon-desktop {}\n\t\t", - m->m_name, sc<int>(m->m_pixelSize.x), sc<int>(m->m_pixelSize.y), m->m_output->name, m->m_output->make, m->m_output->model, m->m_output->serial, - backend(m->m_output->getBackend()->type()), check(m->m_output->supportsExplicit), check(m->m_output->parsedEDID.hdrMetadata.has_value()), - check(m->m_output->parsedEDID.chromaticityCoords.has_value()), check(m->m_output->parsedEDID.supportsBT2020), check(m->m_output->vrrCapable), - check(m->m_output->nonDesktop)); - } - } + auto result = Helpers::SystemInfo::getSystemInfo(); if (g_pHyprCtl && g_pHyprCtl->m_currentRequestParams.sysInfoConfig) { - result += "\n======Config-Start======\n"; + result += "\n\n======Config-Start======\n"; result += Config::mgr()->getConfigString(); result += "\n======Config-End========\n"; } @@ -2097,43 +1924,6 @@ static std::string submapRequest(eHyprCtlOutputFormat format, std::string reques return format == FORMAT_JSON ? std::format("\"{}\"\n", escapeJSONStrings(submap)) : (submap + "\n"); } -static std::string statusRequest(eHyprCtlOutputFormat format, std::string request) { - Aquamarine::eBackendType backendType = Aquamarine::eBackendType::AQ_BACKEND_NULL; - - for (const auto& i : g_pCompositor->m_aqBackend->getImplementations()) { - if (i->type() == Aquamarine::eBackendType::AQ_BACKEND_NULL || i->type() == Aquamarine::eBackendType::AQ_BACKEND_HEADLESS) - continue; - - backendType = i->type(); - break; - } - - std::string backendStr; - - switch (backendType) { - case Aquamarine::AQ_BACKEND_DRM: backendStr = "drm"; break; - case Aquamarine::AQ_BACKEND_WAYLAND: backendStr = "wayland"; break; - default: backendStr = "error"; break; - } - - if (format == eHyprCtlOutputFormat::FORMAT_JSON) { - - return std::format(R"#( -{{ - "configProvider": "{}", - "backend": "{}" -}} -)#", - Config::typeToString(Config::mgr()->type()), backendStr); - } - - return std::format(R"#( -configProvider: {} -backend: {} -)#", - Config::typeToString(Config::mgr()->type()), backendStr); -} - static std::string reloadShaders(eHyprCtlOutputFormat format, std::string request) { CVarList vars(request, 0, ' '); |
