import Quickshell import Quickshell.Io import QtQuick Item { id: root // ===================== // System stats // ===================== property int cpuUsage: 0 property int memUsage: 0 property int gpuUsage: 0 property var lastCpuIdle: 0 property var lastCpuTotal: 0 Process { id: cpuProc command: ["cat", "/proc/stat"] stdout: StdioCollector { onStreamFinished: { var line = this.text.split(/\r?\n/)[1].split(" "); var user = parseInt(line[1]); var nice = parseInt(line[2]); var system = parseInt(line[3]); var idle = parseInt(line[4]); var iowait = parseInt(line[5]); var irq = parseInt(line[6]); var softirq = parseInt(line[7]); var idleAll = idle + iowait; var total = user + nice + system + idle + iowait + irq + softirq; var diffIdle = idleAll - root.lastCpuIdle; var diffTotal = total - root.lastCpuTotal; if (diffTotal > 0) { root.cpuUsage = Math.round(100 * (1 - diffIdle / diffTotal)); } root.lastCpuIdle = idleAll; root.lastCpuTotal = total; } } } Process { id: memProc command: ["sh", "-c", "free | grep Mem"] stdout: SplitParser { onRead: data => { if (!data) return; var parts = data.trim().split(/\s+/); var total = parseInt(parts[1]) || 1; var used = parseInt(parts[2]) || 0; root.memUsage = Math.round(100 * used / total); } } Component.onCompleted: running = true } Process { id: gpuProc command: ["cat", "/sys/class/drm/card1/device/gpu_busy_percent"] stdout: StdioCollector { onStreamFinished: { console.log("GPU usage data:", this.text); if (!this.text) { return; } var gpuUsage = parseInt(this.text.trim()) || 0; root.gpuUsage = gpuUsage; } } } // Update loop Timer { interval: 2000 running: true repeat: true onTriggered: { cpuProc.running = true; memProc.running = true; gpuProc.running = true; } } }