extract cpu service from system stats, add --types filter to nova-stats

This commit is contained in:
Damocles 2026-04-27 19:04:28 +02:00
parent 8628b4b27b
commit 29e06eadb5
7 changed files with 227 additions and 189 deletions

View file

@ -4,9 +4,6 @@ import "../services" as S
Column {
id: root
required property var cores
required property var coreMaxFreq
required property var coreTypes
required property var processes
required property color accentColor
@ -16,34 +13,32 @@ Column {
onActiveChanged: {
if (active && !_coreActive) {
_coreActive = true;
S.SystemStats.coreConsumers++;
S.CpuService.coreConsumers++;
} else if (!active && _coreActive) {
_coreActive = false;
S.SystemStats.coreConsumers--;
S.CpuService.coreConsumers--;
}
if (active)
_cpuHistory = [];
}
Component.onDestruction: if (_coreActive)
S.SystemStats.coreConsumers--
S.CpuService.coreConsumers--
// Per-core rows
Repeater {
model: root.cores.length
model: S.CpuService.cores.length
delegate: Item {
required property int index
width: root.width
readonly property int _u: root.cores[index]?.usage ?? 0
readonly property real _f: root.cores[index]?.freq_ghz ?? 0
readonly property int _u: S.CpuService.cores[index]?.usage ?? 0
readonly property real _f: S.CpuService.cores[index]?.freq_ghz ?? 0
readonly property color _barColor: S.Theme.loadColor(_u)
readonly property bool _throttled: {
const maxF = root.coreMaxFreq[index] ?? 0;
const maxF = S.CpuService.coreMaxFreq[index] ?? 0;
return maxF > 0 && _f < maxF * 0.85 && _u >= 60;
}
readonly property bool _isFirstECore: {
const types = root.coreTypes;
const types = S.CpuService.coreTypes;
if (!types.length || index >= types.length)
return false;
if (types[index] !== "Efficiency")
@ -118,7 +113,7 @@ Column {
anchors.verticalCenter: parent.verticalCenter
width: 32
height: 10
history: root.cores[parent.parent.index]?.history ?? []
history: S.CpuService.cores[parent.parent.index]?.history ?? []
strokeColor: parent.parent._barColor
colorAt: v => S.Theme.loadColor(v)
active: root.active
@ -145,8 +140,8 @@ Column {
// Overall CPU utilization
InfoRow {
label: "Total"
value: S.SystemStats.cpuUsage + "% @ " + S.SystemStats.cpuFreqGhz.toFixed(2) + " GHz"
valueColor: S.Theme.loadColor(S.SystemStats.cpuUsage)
value: S.CpuService.usage + "% @ " + S.CpuService.freqGhz.toFixed(2) + " GHz"
valueColor: S.Theme.loadColor(S.CpuService.usage)
}
SparklineCanvas {
@ -155,23 +150,12 @@ Column {
anchors.right: parent.right
anchors.rightMargin: 12
height: 32
history: root._cpuHistory
history: S.CpuService.history
strokeColor: root.accentColor
colorAt: v => S.Theme.loadColor(v)
active: root.active
}
property var _cpuHistory: []
Connections {
target: S.SystemStats
function onCpuUsageChanged() {
if (!root.active)
return;
const h = root._cpuHistory.concat([S.SystemStats.cpuUsage]);
root._cpuHistory = h.length > 60 ? h.slice(h.length - 60) : h;
}
}
// Process list - hidden on lock screen (exposes running process names)
Column {
visible: !S.LockService.locked