diff --git a/src/debug/HyprCtl.cpp b/src/debug/HyprCtl.cpp index 78c8504a..881d36d9 100644 --- a/src/debug/HyprCtl.cpp +++ b/src/debug/HyprCtl.cpp @@ -14,6 +14,9 @@ #include #include #include +#include +#include +#include #include #include @@ -920,14 +923,24 @@ std::string systemInfoRequest(eHyprCtlOutputFormat format, std::string request) result += "\n\n"; -#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"); -#else - const std::string GPUINFO = execAndGet("lspci -vnn | grep VGA"); -#endif - result += "GPU information: \n" + GPUINFO; + int fd = open("/dev/dri/card0", O_RDONLY | O_CLOEXEC); + if (fd < 0) { + throw std::runtime_error("Failed to open /dev/dri/card0"); + } + drmVersion* version = drmGetVersion(fd); + if (!version) { + close(fd); + throw std::runtime_error("Failed to get DRM version"); + } + const std::string name = version->name ? version->name : "Unknown"; + const std::string description = version->desc ? version->desc : "Unknown"; + std::string GPUINFO = "GPU information:\n"; + GPUINFO += "GPU Type: " + name + "\n"; + GPUINFO += "Driver Description: " + description + "\n"; + + result += GPUINFO; + + if (GPUINFO.contains("NVIDIA") && std::filesystem::exists("/proc/driver/nvidia/version")) result += execAndGet("cat /proc/driver/nvidia/version | grep NVRM"); result += "\n\n"; diff --git a/src/helpers/MiscFunctions.cpp b/src/helpers/MiscFunctions.cpp index 86f24e3a..a7d9f33d 100644 --- a/src/helpers/MiscFunctions.cpp +++ b/src/helpers/MiscFunctions.cpp @@ -13,6 +13,8 @@ #include #include #include +#include +#include #ifdef HAS_EXECINFO #include #endif @@ -609,13 +611,21 @@ void logSystemInfo() { Debug::log(NONE, "\n"); -#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"); -#else - const std::string GPUINFO = execAndGet("lspci -vnn | grep VGA"); -#endif + int fd = open("/dev/dri/card0", O_RDONLY | O_CLOEXEC); + if (fd < 0) { + throw std::runtime_error("Failed to open /dev/dri/card0"); + } + drmVersion* version = drmGetVersion(fd); + if (!version) { + close(fd); + throw std::runtime_error("Failed to get DRM version"); + } + const std::string name = version->name ? version->name : "Unknown"; + const std::string description = version->desc ? version->desc : "Unknown"; + std::string GPUINFO; + GPUINFO += "GPU Type: " + name + "\n"; + GPUINFO += "Driver Description: " + description + "\n"; + Debug::log(LOG, "GPU information:\n{}\n", GPUINFO); if (GPUINFO.contains("NVIDIA")) {