SysMon Service: getting this ready for multiple paths support.

This commit is contained in:
ItsLemmy
2025-10-22 23:38:50 -04:00
parent fb57ba92eb
commit c3439b262c
3 changed files with 17 additions and 10 deletions
+1 -1
View File
@@ -329,7 +329,7 @@ Rectangle {
}
NText {
text: `${SystemStatService.diskPercent}%`
text: `${SystemStatService.diskPercents["/"]}%`
family: Settings.data.ui.fontFixed
pointSize: textSize
applyUiScale: false
@@ -46,7 +46,7 @@ NBox {
Layout.alignment: Qt.AlignHCenter
}
NCircleStat {
value: SystemStatService.diskPercent
value: SystemStatService.diskPercents["/"]
icon: "storage"
flat: true
contentScale: 0.8
+15 -8
View File
@@ -9,18 +9,18 @@ import qs.Commons
Singleton {
id: root
// Configuration
property int sleepDuration: 3000
// Public values
property real cpuUsage: 0
property real cpuTemp: 0
property real memGb: 0
property real memPercent: 0
property real diskPercent: 0
property var diskPercents: ({})
property real rxSpeed: 0
property real txSpeed: 0
// Configuration
property int sleepDuration: 3000
// Internal state for CPU calculation
property var prevCpuStats: null
@@ -94,15 +94,22 @@ Singleton {
// Uses 'df' aka 'disk free'
Process {
id: dfProcess
command: ["df", "--output=pcent", "/"]
command: ["df", "--output=target,pcent"]
running: false
stdout: StdioCollector {
onStreamFinished: {
const lines = text.trim().split('\n')
if (lines.length >= 2) {
const percent = lines[1].replace(/[^0-9]/g, '')
root.diskPercent = parseInt(percent) || 0
const newPercents = {}
// Start from line 1 (skip header)
for (let i = 1; i < lines.length; i++) {
const parts = lines[i].trim().split(/\s+/)
if (parts.length >= 2) {
const target = parts[0]
const percent = parseInt(parts[1].replace(/[^0-9]/g, '')) || 0
newPercents[target] = percent
}
}
root.diskPercents = newPercents
}
}
}