Using a bash script for SystemStats instead of ZigStat
This commit is contained in:
parent
b68d5c9f4c
commit
d009b8d5c8
8 changed files with 234 additions and 160 deletions
37
Services/SystemStats.qml
Normal file
37
Services/SystemStats.qml
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
pragma Singleton
|
||||
|
||||
import QtQuick
|
||||
import Qt.labs.folderlistmodel
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
|
||||
Singleton {
|
||||
id: root
|
||||
|
||||
// Public values
|
||||
property real cpuUsage: 0
|
||||
property real cpuTemp: 0
|
||||
property real memoryUsagePer: 0
|
||||
property real diskUsage: 0
|
||||
|
||||
// Background process emitting one JSON line per sample
|
||||
Process {
|
||||
id: reader
|
||||
running: true
|
||||
command: ["sh", "-c", Quickshell.shellDir + "/Bin/system-stats.sh"]
|
||||
stdout: SplitParser {
|
||||
onRead: function (line) {
|
||||
try {
|
||||
const data = JSON.parse(line)
|
||||
root.cpuUsage = data.cpu
|
||||
root.cpuTemp = data.cputemp
|
||||
root.memoryUsagePer = data.memper
|
||||
root.diskUsage = data.diskper
|
||||
} catch (e) {
|
||||
|
||||
// ignore malformed lines
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue