diff --git a/src/debug/HyprCtl.cpp b/src/debug/HyprCtl.cpp index 78c8504a1a0..c0559da957c 100644 --- a/src/debug/HyprCtl.cpp +++ b/src/debug/HyprCtl.cpp @@ -14,6 +14,9 @@ #include #include #include +#include +#include +#include #include #include @@ -920,17 +923,25 @@ 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; - if (GPUINFO.contains("NVIDIA") && std::filesystem::exists("/proc/driver/nvidia/version")) - result += execAndGet("cat /proc/driver/nvidia/version | grep NVRM"); - result += "\n\n"; + int fd = open("/dev/dri/card0", O_RDONLY | O_CLOEXEC); + if (fd > 0) { + drmVersion* version = drmGetVersion(fd); + + 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; + drmFreeVersion(version); + close(fd); + + if (GPUINFO.contains("NVIDIA") && std::filesystem::exists("/proc/driver/nvidia/version")) + result += execAndGet("cat /proc/driver/nvidia/version | grep NVRM"); + + result += "\n\n"; + } result += "os-release: " + execAndGet("cat /etc/os-release") + "\n\n"; diff --git a/src/helpers/MiscFunctions.cpp b/src/helpers/MiscFunctions.cpp index 86f24e3a6e9..cf45730b30e 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,17 +611,23 @@ 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 - Debug::log(LOG, "GPU information:\n{}\n", GPUINFO); + int fd = open("/dev/dri/card0", O_RDONLY | O_CLOEXEC); + if (fd > 0) { + drmVersion* version = drmGetVersion(fd); + + 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"; - if (GPUINFO.contains("NVIDIA")) { - Debug::log(WARN, "Warning: you're using an NVIDIA GPU. Make sure you follow the instructions on the wiki if anything is amiss.\n"); + Debug::log(LOG, "{}\n", GPUINFO); + drmFreeVersion(version); + close(fd); + + if (GPUINFO.contains("NVIDIA")) { + Debug::log(WARN, "Warning: you're using an NVIDIA GPU. Make sure you follow the instructions on the wiki if anything is amiss.\n"); + } } // log etc