This commit is contained in:
system64fumo 2024-08-23 17:10:31 +03:00
parent c4576043df
commit 8880fccf1b
2 changed files with 30 additions and 37 deletions

View file

@ -924,27 +924,24 @@ std::string systemInfoRequest(eHyprCtlOutputFormat format, std::string request)
result += "\n\n"; result += "\n\n";
int fd = open("/dev/dri/card0", O_RDONLY | O_CLOEXEC); int fd = open("/dev/dri/card0", O_RDONLY | O_CLOEXEC);
if (fd < 0) { if (fd > 0) {
throw std::runtime_error("Failed to open /dev/dri/card0"); drmVersion* version = drmGetVersion(fd);
}
drmVersion* version = drmGetVersion(fd); const std::string name = version->name ? version->name : "Unknown";
if (!version) { 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); 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"; result += "os-release: " + execAndGet("cat /etc/os-release") + "\n\n";

View file

@ -612,26 +612,22 @@ void logSystemInfo() {
Debug::log(NONE, "\n"); Debug::log(NONE, "\n");
int fd = open("/dev/dri/card0", O_RDONLY | O_CLOEXEC); int fd = open("/dev/dri/card0", O_RDONLY | O_CLOEXEC);
if (fd < 0) { if (fd > 0) {
throw std::runtime_error("Failed to open /dev/dri/card0"); drmVersion* version = drmGetVersion(fd);
}
drmVersion* version = drmGetVersion(fd); const std::string name = version->name ? version->name : "Unknown";
if (!version) { 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); 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")) {
drmFreeVersion(version); Debug::log(WARN, "Warning: you're using an NVIDIA GPU. Make sure you follow the instructions on the wiki if anything is amiss.\n");
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 // log etc