37 lines
889 B
QML
37 lines
889 B
QML
pragma Singleton
|
|
import Quickshell
|
|
import Quickshell.Io
|
|
import QtQuick
|
|
|
|
Singleton {
|
|
id: root
|
|
|
|
property int usage: 0
|
|
property int temp: 0
|
|
|
|
Timer {
|
|
interval: 2000
|
|
running: true
|
|
repeat: true
|
|
triggeredOnStart: true
|
|
onTriggered: {
|
|
_proc.running = false
|
|
_proc.running = true
|
|
}
|
|
}
|
|
|
|
Process {
|
|
id: _proc
|
|
command: ["nvidia-smi", "--query-gpu=utilization.gpu,temperature.gpu", "--format=csv,noheader,nounits"]
|
|
stdout: SplitParser {
|
|
onRead: line => {
|
|
const parts = line.trim().split(/\s*,\s*/)
|
|
if (parts.length < 2) return
|
|
const u = parseInt(parts[0])
|
|
const t = parseInt(parts[1])
|
|
if (!isNaN(u)) root.usage = u
|
|
if (!isNaN(t)) root.temp = t
|
|
}
|
|
}
|
|
}
|
|
}
|