aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorWavyEbuilder <[email protected]>2024-11-10 15:54:15 +0000
committerGitHub <[email protected]>2024-11-10 15:54:15 +0000
commit9e628067fc54851dc9138c2882abb21f72c5a5a6 (patch)
treef1ffa2e29cf6612a20d7124498846f54ddd9548d
parent99b01c5d124d08648d4c9e6754485ea585c42707 (diff)
downloadHyprland-9e628067fc54851dc9138c2882abb21f72c5a5a6.tar.gz
Hyprland-9e628067fc54851dc9138c2882abb21f72c5a5a6.zip
debug: clean up opening of files in HyprCtl (#8401)
`std::ifstream` is more suited than `execAndGet` here.
-rw-r--r--src/debug/HyprCtl.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/debug/HyprCtl.cpp b/src/debug/HyprCtl.cpp
index 3e0c75a6..709d8b69 100644
--- a/src/debug/HyprCtl.cpp
+++ b/src/debug/HyprCtl.cpp
@@ -1,6 +1,7 @@
#include "HyprCtl.hpp"
#include <format>
+#include <fstream>
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
@@ -949,11 +950,27 @@ std::string systemInfoRequest(eHyprCtlOutputFormat format, std::string request)
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");
+ if (GPUINFO.contains("NVIDIA") && std::filesystem::exists("/proc/driver/nvidia/version")) {
+ std::ifstream file("/proc/driver/nvidia/version");
+ std::string line;
+ if (file.is_open()) {
+ while (std::getline(file, line)) {
+ if (!line.contains("NVRM"))
+ continue;
+ result += line;
+ result += "\n";
+ }
+ } else
+ result += "error";
+ }
result += "\n\n";
- result += "os-release: " + execAndGet("cat /etc/os-release") + "\n\n";
+ if (std::ifstream file("/etc/os-release"); file.is_open()) {
+ std::stringstream buffer;
+ buffer << file.rdbuf();
+ result += "os-release: " + buffer.str() + "\n\n";
+ } else
+ result += "os-release: error\n\n";
result += "plugins:\n";
if (g_pPluginSystem) {