From 8880fccf1b5f638d084463abba7032f0a012a7f4 Mon Sep 17 00:00:00 2001 From: system64fumo Date: Fri, 23 Aug 2024 17:10:31 +0300 Subject: [PATCH] Cleanup --- src/debug/HyprCtl.cpp | 35 ++++++++++++++++------------------- src/helpers/MiscFunctions.cpp | 32 ++++++++++++++------------------ 2 files changed, 30 insertions(+), 37 deletions(-) diff --git a/src/debug/HyprCtl.cpp b/src/debug/HyprCtl.cpp index f9403c6b..c0559da9 100644 --- a/src/debug/HyprCtl.cpp +++ b/src/debug/HyprCtl.cpp @@ -924,27 +924,24 @@ std::string systemInfoRequest(eHyprCtlOutputFormat format, std::string request) result += "\n\n"; 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) { + 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); - throw std::runtime_error("Failed to get DRM version"); + + if (GPUINFO.contains("NVIDIA") && std::filesystem::exists("/proc/driver/nvidia/version")) + result += execAndGet("cat /proc/driver/nvidia/version | grep NVRM"); + + result += "\n\n"; } - 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 e469301e..cf45730b 100644 --- a/src/helpers/MiscFunctions.cpp +++ b/src/helpers/MiscFunctions.cpp @@ -612,26 +612,22 @@ void logSystemInfo() { Debug::log(NONE, "\n"); 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) { + 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"; + + Debug::log(LOG, "{}\n", GPUINFO); + drmFreeVersion(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); - 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"); + 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