mirror of
https://github.com/hyprwm/hyprsysteminfo.git
synced 2024-11-24 06:55:59 +01:00
core: fixup elision on gpu data
This commit is contained in:
parent
1562ce6415
commit
a2028419fc
3 changed files with 33 additions and 21 deletions
|
@ -159,8 +159,13 @@ ApplicationWindow {
|
||||||
wrapMode: Text.NoWrap
|
wrapMode: Text.NoWrap
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Repeater {
|
||||||
|
model: hsi.getGPUInfoCount()
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
text: hsi.getGPUInfo()
|
required property int index
|
||||||
|
|
||||||
|
text: "GPU: " + hsi.getGPUInfo(index)
|
||||||
Layout.maximumWidth: _width - 120
|
Layout.maximumWidth: _width - 120
|
||||||
color: system.windowText
|
color: system.windowText
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
|
@ -168,6 +173,8 @@ ApplicationWindow {
|
||||||
wrapMode: Text.NoWrap
|
wrapMode: Text.NoWrap
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
text: "Memory: " + hsi.getRAMInfo()
|
text: "Memory: " + hsi.getRAMInfo()
|
||||||
Layout.maximumWidth: _width - 120
|
Layout.maximumWidth: _width - 120
|
||||||
|
|
|
@ -18,7 +18,7 @@ class CSystemInternals : public QObject {
|
||||||
QString hyprlandVersion, hyprlandVersionLong;
|
QString hyprlandVersion, hyprlandVersionLong;
|
||||||
|
|
||||||
QString cpuInfo = "missing dependency: lscpu";
|
QString cpuInfo = "missing dependency: lscpu";
|
||||||
QString gpuInfo = "GPU: missing dependency: lspci";
|
std::vector<QString> gpuInfo = {"missing dependency: lspci"};
|
||||||
QString ramInfo = "?";
|
QString ramInfo = "?";
|
||||||
|
|
||||||
QString hlSystemInfo = "[error]", hlSystemVersion = "[error]";
|
QString hlSystemInfo = "[error]", hlSystemVersion = "[error]";
|
||||||
|
@ -59,8 +59,14 @@ class CSystemInternals : public QObject {
|
||||||
return cpuInfo;
|
return cpuInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_INVOKABLE QString getGPUInfo() {
|
Q_INVOKABLE int getGPUInfoCount() {
|
||||||
return gpuInfo;
|
return gpuInfo.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_INVOKABLE QString getGPUInfo(int idx) {
|
||||||
|
if (idx >= gpuInfo.size())
|
||||||
|
return "[error]";
|
||||||
|
return gpuInfo.at(idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_INVOKABLE QString getRAMInfo() {
|
Q_INVOKABLE QString getRAMInfo() {
|
||||||
|
|
|
@ -106,15 +106,14 @@ static void getSystemInfo(CSystemInternals* hsi) {
|
||||||
const auto DATA = execAndGet("lspci -vnn | grep VGA");
|
const auto DATA = execAndGet("lspci -vnn | grep VGA");
|
||||||
if (DATA.contains("VGA")) {
|
if (DATA.contains("VGA")) {
|
||||||
CVarList data(DATA, 0, '\n');
|
CVarList data(DATA, 0, '\n');
|
||||||
std::string gpuInfo;
|
hsi->gpuInfo.clear();
|
||||||
for (auto& line : data) {
|
for (auto& line : data) {
|
||||||
if (!line.contains("VGA"))
|
if (!line.contains("VGA"))
|
||||||
continue;
|
continue;
|
||||||
gpuInfo += std::format("GPU: {}\n", line.substr(line.find(":", line.find("VGA")) + 1));
|
hsi->gpuInfo.emplace_back(std::format("{}", line.substr(line.find(":", line.find("VGA")) + 2)).c_str());
|
||||||
}
|
}
|
||||||
hsi->gpuInfo = gpuInfo.substr(0, gpuInfo.length() - 1).c_str();
|
|
||||||
} else {
|
} else {
|
||||||
hsi->gpuInfo = "No GPUs found";
|
hsi->gpuInfo = {"No GPUs found"};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue