dashboard: optimise systemusage
Ref same way as cava
This commit is contained in:
parent
c1872c2d77
commit
40b43a49ab
3 changed files with 13 additions and 9 deletions
|
|
@ -11,6 +11,10 @@ RowLayout {
|
|||
|
||||
spacing: Appearance.spacing.large * 3
|
||||
|
||||
Ref {
|
||||
service: SystemUsage
|
||||
}
|
||||
|
||||
Resource {
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
Layout.topMargin: root.padding
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import "root:/widgets"
|
|||
import "root:/services"
|
||||
import "root:/config"
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
|
||||
Row {
|
||||
id: root
|
||||
|
|
@ -13,6 +12,10 @@ Row {
|
|||
padding: Appearance.padding.large
|
||||
spacing: Appearance.spacing.normal
|
||||
|
||||
Ref {
|
||||
service: SystemUsage
|
||||
}
|
||||
|
||||
Resource {
|
||||
icon: "memory"
|
||||
value: SystemUsage.cpuPerc
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ Singleton {
|
|||
property real lastCpuIdle
|
||||
property real lastCpuTotal
|
||||
|
||||
property int refCount
|
||||
|
||||
function formatKib(kib: real): var {
|
||||
const mib = 1024;
|
||||
const gib = 1024 ** 2;
|
||||
|
|
@ -49,9 +51,10 @@ Singleton {
|
|||
}
|
||||
|
||||
Timer {
|
||||
running: true
|
||||
running: root.refCount
|
||||
interval: 3000
|
||||
repeat: true
|
||||
triggeredOnStart: true
|
||||
onTriggered: {
|
||||
stat.reload();
|
||||
meminfo.reload();
|
||||
|
|
@ -96,7 +99,6 @@ Singleton {
|
|||
Process {
|
||||
id: storage
|
||||
|
||||
running: true
|
||||
command: ["sh", "-c", "df | grep '^/dev/' | awk '{print $1, $3, $4}'"]
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: {
|
||||
|
|
@ -142,17 +144,13 @@ Singleton {
|
|||
running: true
|
||||
command: ["sh", "-c", "if ls /sys/class/drm/card*/device/gpu_busy_percent 2>/dev/null | grep -q .; then echo GENERIC; elif command -v nvidia-smi >/dev/null; then echo NVIDIA; else echo NONE; fi"]
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: {
|
||||
root.gpuType = text.trim();
|
||||
gpuUsage.running = true;
|
||||
}
|
||||
onStreamFinished: root.gpuType = text.trim()
|
||||
}
|
||||
}
|
||||
|
||||
Process {
|
||||
id: gpuUsage
|
||||
|
||||
running: true
|
||||
command: root.gpuType === "GENERIC" ? ["sh", "-c", "cat /sys/class/drm/card*/device/gpu_busy_percent"] : root.gpuType === "NVIDIA" ? ["nvidia-smi", "--query-gpu=utilization.gpu,temperature.gpu", "--format=csv,noheader,nounits"] : ["echo"]
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: {
|
||||
|
|
@ -175,7 +173,6 @@ Singleton {
|
|||
Process {
|
||||
id: sensors
|
||||
|
||||
running: true
|
||||
command: ["sensors"]
|
||||
environment: ({
|
||||
LANG: "C",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue