diff options
| author | WavyEbuilder <rahul@sandhuservices.dev> | 2024-11-11 13:44:41 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-11-11 13:44:41 +0000 |
| commit | 1fa0cd7a7574c8e93c567bf0453c155285dd3960 (patch) | |
| tree | 0470226a699ac0bd5f94bf5e9f5a02825adbef79 /src/debug/HyprCtl.cpp | |
| parent | c10739e6e35c30ef5f273bfe5d219d361a31e226 (diff) | |
debug: clean up fetching of the contents of /proc/device-tree (#8413)
Diffstat (limited to 'src/debug/HyprCtl.cpp')
| -rw-r--r-- | src/debug/HyprCtl.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/debug/HyprCtl.cpp b/src/debug/HyprCtl.cpp index 709d8b69..6429e781 100644 --- a/src/debug/HyprCtl.cpp +++ b/src/debug/HyprCtl.cpp @@ -1,7 +1,9 @@ #include "HyprCtl.hpp" +#include <algorithm> #include <format> #include <fstream> +#include <iterator> #include <netinet/in.h> #include <stdio.h> #include <stdlib.h> @@ -945,7 +947,24 @@ std::string systemInfoRequest(eHyprCtlOutputFormat format, std::string request) #if defined(__DragonFly__) || defined(__FreeBSD__) const std::string GPUINFO = execAndGet("pciconf -lv | fgrep -A4 vga"); #elif defined(__arm__) || defined(__aarch64__) - const std::string GPUINFO = execAndGet("cat /proc/device-tree/soc*/gpu*/compatible"); + 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 VGA"); #endif |
