systemusage: add fallback for amd gpus

If they dont have edge, try use junction/mem
This commit is contained in:
2 * r + 2 * t 2025-06-25 00:54:38 +10:00
parent 9c4cab53b8
commit cebb6270e4

View file

@ -184,10 +184,10 @@ Singleton {
stdout: StdioCollector {
onStreamFinished: {
let cpuTemp = text.match(/(?:Package id [0-9]+|Tdie):\s+((\+|-)[0-9.]+)(°| )C/);
if (!cpuTemp) {
if (!cpuTemp)
// If AMD Tdie pattern failed, try fallback on Tctl
cpuTemp = text.match(/Tctl:\s+((\+|-)[0-9.]+)(°| )C/);
}
if (cpuTemp)
root.cpuTemp = parseFloat(cpuTemp[1]);
@ -204,7 +204,11 @@ Singleton {
else if (line === "")
eligible = false;
else if (eligible) {
const match = line.match(/^(temp[0-9]+|GPU core|edge)+:\s+\+([0-9]+\.[0-9]+)(°| )C/);
let match = line.match(/^(temp[0-9]+|GPU core|edge)+:\s+\+([0-9]+\.[0-9]+)(°| )C/);
if (!match)
// Fall back to junction/mem if GPU doesn't have edge temp (for AMD GPUs)
match = line.match(/^(junction|mem)+:\s+\+([0-9]+\.[0-9]+)(°| )C/);
if (match) {
sum += parseFloat(match[2]);
count++;