Merge settings window to main #23
+49
-27
@@ -17,7 +17,6 @@ Singleton {
|
|||||||
property var disks: []
|
property var disks: []
|
||||||
property real gpuMemTotal: 0
|
property real gpuMemTotal: 0
|
||||||
property real gpuMemUsed
|
property real gpuMemUsed
|
||||||
property string gpuName: ""
|
|
||||||
property real gpuPerc
|
property real gpuPerc
|
||||||
property real gpuTemp
|
property real gpuTemp
|
||||||
readonly property string gpuType: Config.services.gpuType.toUpperCase() || autoGpuType
|
readonly property string gpuType: Config.services.gpuType.toUpperCase() || autoGpuType
|
||||||
@@ -80,9 +79,19 @@ Singleton {
|
|||||||
onTriggered: {
|
onTriggered: {
|
||||||
stat.reload();
|
stat.reload();
|
||||||
meminfo.reload();
|
meminfo.reload();
|
||||||
storage.running = false;
|
storage.running = true;
|
||||||
if (root.gpuName === "GENERIC")
|
if (root.gpuType === "GENERIC")
|
||||||
gpuUsage.running = true;
|
gpuUsage.running = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
interval: Config.dashboard.resourceUpdateInterval * 5
|
||||||
|
repeat: true
|
||||||
|
running: root.refCount > 0
|
||||||
|
triggeredOnStart: true
|
||||||
|
|
||||||
|
onTriggered: {
|
||||||
sensors.running = true;
|
sensors.running = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -113,10 +122,13 @@ Singleton {
|
|||||||
|
|
||||||
const totalDiff = total - root.lastCpuTotal;
|
const totalDiff = total - root.lastCpuTotal;
|
||||||
const idleDiff = idle - root.lastCpuIdle;
|
const idleDiff = idle - root.lastCpuIdle;
|
||||||
root.cpuPerc = totalDiff > 0 ? (1 - idleDiff / totalDiff) : 0;
|
const newCpuPerc = totalDiff > 0 ? (1 - idleDiff / totalDiff) : 0;
|
||||||
|
|
||||||
root.lastCpuTotal = total;
|
root.lastCpuTotal = total;
|
||||||
root.lastCpuIdle = idle;
|
root.lastCpuIdle = idle;
|
||||||
|
|
||||||
|
if (Math.abs(newCpuPerc - root.cpuPerc) >= 0.01)
|
||||||
|
root.cpuPerc = newCpuPerc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -128,8 +140,14 @@ Singleton {
|
|||||||
|
|
||||||
onLoaded: {
|
onLoaded: {
|
||||||
const data = text();
|
const data = text();
|
||||||
root.memTotal = parseInt(data.match(/MemTotal: *(\d+)/)[1], 10) || 1;
|
const total = parseInt(data.match(/MemTotal: *(\d+)/)[1], 10) || 1;
|
||||||
root.memUsed = (root.memTotal - parseInt(data.match(/MemAvailable: *(\d+)/)[1], 10)) || 0;
|
const used = (root.memTotal - parseInt(data.match(/MemAvailable: *(\d+)/)[1], 10)) || 0;
|
||||||
|
|
||||||
|
if (root.memTotal !== total)
|
||||||
|
root.memTotal = total;
|
||||||
|
|
||||||
|
if (Math.abs(used - root.memUsed) >= 16384)
|
||||||
|
root.memUsed = used;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -279,27 +297,36 @@ Singleton {
|
|||||||
id: gpuUsageNvidia
|
id: gpuUsageNvidia
|
||||||
|
|
||||||
command: ["/usr/bin/nvidia-smi", "--query-gpu=utilization.gpu,temperature.gpu,memory.used", "--format=csv,noheader,nounits", "-lms", "1000"]
|
command: ["/usr/bin/nvidia-smi", "--query-gpu=utilization.gpu,temperature.gpu,memory.used", "--format=csv,noheader,nounits", "-lms", "1000"]
|
||||||
running: true
|
running: root.refCount > 0 && root.gpuType === "NVIDIA"
|
||||||
|
|
||||||
stderr: SplitParser {
|
|
||||||
onRead: data => {
|
|
||||||
console.log("nvidia-smi stderr:", String(data).trim());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stdout: SplitParser {
|
stdout: SplitParser {
|
||||||
onRead: data => {
|
onRead: data => {
|
||||||
const [usage, temp, mem] = String(data).trim().split(/\s*,\s*/);
|
const parts = String(data).trim().split(/\s*,\s*/);
|
||||||
|
if (parts.length < 3)
|
||||||
|
return;
|
||||||
|
|
||||||
root.gpuPerc = parseInt(usage, 10) / 100;
|
const usageRaw = parseInt(parts[0], 10);
|
||||||
root.gpuTemp = parseInt(temp, 10);
|
const tempRaw = parseInt(parts[1], 10);
|
||||||
root.gpuMemUsed = parseInt(mem, 10) / root.gpuMemTotal;
|
const memRaw = parseInt(parts[2], 10);
|
||||||
|
|
||||||
|
if (!Number.isFinite(usageRaw) || !Number.isFinite(tempRaw) || !Number.isFinite(memRaw))
|
||||||
|
return;
|
||||||
|
|
||||||
|
const newGpuPerc = Math.max(0, Math.min(1, usageRaw / 100));
|
||||||
|
const newGpuTemp = tempRaw;
|
||||||
|
const newGpuMemUsed = root.gpuMemTotal > 0 ? Math.max(0, Math.min(1, memRaw / root.gpuMemTotal)) : 0;
|
||||||
|
|
||||||
|
// Only publish meaningful changes to avoid needless binding churn / repaints
|
||||||
|
if (Math.abs(root.gpuPerc - newGpuPerc) >= 0.01)
|
||||||
|
root.gpuPerc = newGpuPerc;
|
||||||
|
|
||||||
|
if (Math.abs(root.gpuTemp - newGpuTemp) >= 1)
|
||||||
|
root.gpuTemp = newGpuTemp;
|
||||||
|
|
||||||
|
if (Math.abs(root.gpuMemUsed - newGpuMemUsed) >= 0.01)
|
||||||
|
root.gpuMemUsed = newGpuMemUsed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onExited: (exitCode, exitStatus) => {
|
|
||||||
console.log("gpuUsageNvidia exited:", exitCode, exitStatus);
|
|
||||||
}
|
|
||||||
onStarted: console.log("gpuUsageNvidia started, pid =", processId)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Process {
|
Process {
|
||||||
@@ -314,11 +341,6 @@ Singleton {
|
|||||||
const percs = text.trim().split("\n");
|
const percs = text.trim().split("\n");
|
||||||
const sum = percs.reduce((acc, d) => acc + parseInt(d, 10), 0);
|
const sum = percs.reduce((acc, d) => acc + parseInt(d, 10), 0);
|
||||||
root.gpuPerc = sum / percs.length / 100;
|
root.gpuPerc = sum / percs.length / 100;
|
||||||
} else if (root.gpuType === "NVIDIA") {
|
|
||||||
const [usage, temp, mem] = text.trim().split(",");
|
|
||||||
root.gpuPerc = parseInt(usage, 10) / 100;
|
|
||||||
root.gpuTemp = parseInt(temp, 10);
|
|
||||||
root.gpuMemUsed = parseInt(mem, 10) / root.gpuMemTotal;
|
|
||||||
} else {
|
} else {
|
||||||
root.gpuPerc = 0;
|
root.gpuPerc = 0;
|
||||||
root.gpuTemp = 0;
|
root.gpuTemp = 0;
|
||||||
@@ -343,7 +365,7 @@ Singleton {
|
|||||||
// If AMD Tdie pattern failed, try fallback on Tctl
|
// If AMD Tdie pattern failed, try fallback on Tctl
|
||||||
cpuTemp = text.match(/Tctl:\s+((\+|-)[0-9.]+)(°| )C/);
|
cpuTemp = text.match(/Tctl:\s+((\+|-)[0-9.]+)(°| )C/);
|
||||||
|
|
||||||
if (cpuTemp)
|
if (cpuTemp && Math.abs(parseFloat(cpuTemp[1]) - root.cpuTemp) >= 0.5)
|
||||||
root.cpuTemp = parseFloat(cpuTemp[1]);
|
root.cpuTemp = parseFloat(cpuTemp[1]);
|
||||||
|
|
||||||
if (root.gpuType !== "GENERIC")
|
if (root.gpuType !== "GENERIC")
|
||||||
|
|||||||
+47
-64
@@ -36,75 +36,58 @@ Item {
|
|||||||
Component.onCompleted: animatedPercentage = percentage
|
Component.onCompleted: animatedPercentage = percentage
|
||||||
onPercentageChanged: animatedPercentage = percentage
|
onPercentageChanged: animatedPercentage = percentage
|
||||||
|
|
||||||
// Canvas {
|
Canvas {
|
||||||
// id: gaugeCanvas
|
id: gaugeCanvas
|
||||||
//
|
|
||||||
// anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
// height: width
|
height: width
|
||||||
// width: Math.min(parent.width, parent.height)
|
width: Math.min(parent.width, parent.height)
|
||||||
//
|
|
||||||
// Component.onCompleted: requestPaint()
|
Component.onCompleted: requestPaint()
|
||||||
// onPaint: {
|
onPaint: {
|
||||||
// const ctx = getContext("2d");
|
const ctx = getContext("2d");
|
||||||
// ctx.reset();
|
ctx.reset();
|
||||||
// const cx = width / 2;
|
const cx = width / 2;
|
||||||
// const cy = (height / 2) + 1;
|
const cy = (height / 2) + 1;
|
||||||
// const radius = (Math.min(width, height) - 12) / 2;
|
const radius = (Math.min(width, height) - 12) / 2;
|
||||||
// const lineWidth = 3;
|
const lineWidth = 3;
|
||||||
// ctx.beginPath();
|
ctx.beginPath();
|
||||||
// ctx.arc(cx, cy, radius, root.arcStartAngle, root.arcStartAngle + root.arcSweep);
|
ctx.arc(cx, cy, radius, root.arcStartAngle, root.arcStartAngle + root.arcSweep);
|
||||||
// ctx.lineWidth = lineWidth;
|
ctx.lineWidth = lineWidth;
|
||||||
// ctx.lineCap = "round";
|
ctx.lineCap = "round";
|
||||||
// ctx.strokeStyle = DynamicColors.layer(DynamicColors.palette.m3surfaceContainerHigh, 2);
|
ctx.strokeStyle = DynamicColors.layer(DynamicColors.palette.m3surfaceContainerHigh, 2);
|
||||||
// ctx.stroke();
|
ctx.stroke();
|
||||||
// if (root.animatedPercentage > 0) {
|
if (root.animatedPercentage > 0) {
|
||||||
// ctx.beginPath();
|
ctx.beginPath();
|
||||||
// ctx.arc(cx, cy, radius, root.arcStartAngle, root.arcStartAngle + root.arcSweep * root.animatedPercentage);
|
ctx.arc(cx, cy, radius, root.arcStartAngle, root.arcStartAngle + root.arcSweep * root.animatedPercentage);
|
||||||
// ctx.lineWidth = lineWidth;
|
ctx.lineWidth = lineWidth;
|
||||||
// ctx.lineCap = "round";
|
ctx.lineCap = "round";
|
||||||
// ctx.strokeStyle = root.accentColor;
|
ctx.strokeStyle = root.accentColor;
|
||||||
// ctx.stroke();
|
ctx.stroke();
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// Connections {
|
Connections {
|
||||||
// function onAnimatedPercentageChanged() {
|
function onAnimatedPercentageChanged() {
|
||||||
// gaugeCanvas.requestPaint();
|
gaugeCanvas.requestPaint();
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// target: root
|
target: root
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// Connections {
|
Connections {
|
||||||
// function onPaletteChanged() {
|
function onPaletteChanged() {
|
||||||
// gaugeCanvas.requestPaint();
|
gaugeCanvas.requestPaint();
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// target: DynamicColors
|
target: DynamicColors
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
MaterialIcon {
|
MaterialIcon {
|
||||||
id: icon
|
|
||||||
|
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
color: DynamicColors.palette.m3onSurface
|
color: DynamicColors.palette.m3onSurface
|
||||||
font.pointSize: 12
|
font.pointSize: 12
|
||||||
text: root.icon
|
text: root.icon
|
||||||
}
|
}
|
||||||
|
|
||||||
CustomRect {
|
|
||||||
anchors.left: icon.right
|
|
||||||
color: DynamicColors.layer(DynamicColors.palette.m3surfaceContainerHigh, 2)
|
|
||||||
implicitHeight: parent.height
|
|
||||||
implicitWidth: 5
|
|
||||||
radius: Appearance.rounding.full
|
|
||||||
|
|
||||||
CustomRect {
|
|
||||||
anchors.bottom: parent.bottom
|
|
||||||
anchors.left: parent.left
|
|
||||||
anchors.right: parent.right
|
|
||||||
color: root.mainColor
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//@ pragma UseQApplication
|
//@ pragma UseQApplication
|
||||||
//@ pragma Env QSG_RENDER_LOOP=threaded
|
//@ pragma Env QSG_RENDER_LOOP=threaded
|
||||||
//@ pragma Env QSG_USE_SIMPLE_ANIMATION_DRIVER=1
|
//@ pragma Env QSG_USE_SIMPLE_ANIMATION_DRIVER=0
|
||||||
//@ pragma Env QS_NO_RELOAD_POPUP=1
|
//@ pragma Env QS_NO_RELOAD_POPUP=1
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import qs.Modules
|
import qs.Modules
|
||||||
|
|||||||
Reference in New Issue
Block a user