Add tabs, a performance page and a mixer button to Quick Settings

This commit is contained in:
SirBlob committed 2026-09-24 12:37:35 -04:00
1 parent 3164e50b36
commit 0ed5e22fc6
11 files changed
+520 -158

No files matched your search

+15 -108
View File
@@ -14,16 +14,6 @@ Item {
readonly property string pluginId: (manifest && manifest.id) || "blob.sysmon"
property int cpuPercent: 0
property int memoryPercent: 0
property string memoryDetail: ""
property int diskPercent: 0
property string diskDetail: ""
property int temperature: 0
property real previousIdle: 0
property real previousTotal: 0
function open(payloadJson) {
root.opened = true
}
@@ -38,92 +28,9 @@ Item {
root.shell.hide(root.pluginId)
}
function readCpu(raw) {
var values = String(raw).trim().split(/\s+/).slice(1).map(Number)
var idle = (values[3] || 0) + (values[4] || 0)
var total = 0
for (var i = 0; i < values.length; i++) total += values[i] || 0
var idleDelta = idle - root.previousIdle
var totalDelta = total - root.previousTotal
root.previousIdle = idle
root.previousTotal = total
if (totalDelta <= 0) return
root.cpuPercent = Math.round((1 - idleDelta / totalDelta) * 100)
}
function readMemory(raw) {
var parts = String(raw).trim().split(/\s+/).map(Number)
var used = parts[0] || 0
var total = parts[1] || 0
if (!total) {
root.memoryPercent = 0
root.memoryDetail = ""
return
}
root.memoryPercent = Math.round(used / total * 100)
root.memoryDetail = (used / 1024).toFixed(1) + "G / " + (total / 1024).toFixed(1) + "G"
}
function readDisk(raw) {
var parts = String(raw).trim().split(/\s+/)
root.diskPercent = Number(String(parts[0] || "").replace("%", "")) || 0
root.diskDetail = (parts[1] || "0") + " / " + (parts[2] || "0")
}
Process {
id: cpuProbe
command: ["bash", "-c", "grep '^cpu ' /proc/stat"]
stdout: StdioCollector { onStreamFinished: root.readCpu(text) }
}
Process {
id: memoryProbe
command: ["bash", "-c", "free -m | awk '/^Mem:/ {print $3\" \"$2}'"]
stdout: StdioCollector { onStreamFinished: root.readMemory(text) }
}
Process {
id: diskProbe
command: ["bash", "-c", "df -h --output=pcent,used,size / | tail -1"]
stdout: StdioCollector { onStreamFinished: root.readDisk(text) }
}
Process {
id: temperatureProbe
command: ["bash", "-c", "cat /sys/class/thermal/thermal_zone0/temp 2>/dev/null || echo 0"]
stdout: StdioCollector {
onStreamFinished: root.temperature = Math.round(Number(String(text).trim()) / 1000) || 0
}
}
function refreshFast() {
if (!cpuProbe.running) cpuProbe.running = true
if (!memoryProbe.running) memoryProbe.running = true
if (!temperatureProbe.running) temperatureProbe.running = true
}
function refreshSlow() {
if (!diskProbe.running) diskProbe.running = true
}
Timer {
interval: 2000
running: root.opened
repeat: true
onTriggered: root.refreshFast()
}
Timer {
interval: 30000
running: root.opened
repeat: true
onTriggered: root.refreshSlow()
}
onOpenedChanged: {
if (!root.opened) return
root.refreshFast()
root.refreshSlow()
SystemStats {
id: stats
polling: root.opened
}
PanelWindow {
@@ -158,36 +65,36 @@ Item {
font.bold: true
}
Metric {
MetricBar {
width: parent.width
icon: "󰍛"
name: "CPU"
percent: root.cpuPercent
detail: root.cpuPercent + "%"
percent: stats.cpuPercent
detail: stats.cpuPercent + "%"
}
Metric {
MetricBar {
width: parent.width
icon: "󰘚"
name: "Memory"
percent: root.memoryPercent
detail: root.memoryDetail
percent: stats.memoryPercent
detail: stats.memoryDetail
}
Metric {
MetricBar {
width: parent.width
icon: "󰋊"
name: "Disk"
percent: root.diskPercent
detail: root.diskDetail
percent: stats.diskPercent
detail: stats.diskDetail
}
Metric {
MetricBar {
width: parent.width
icon: ""
name: "Temperature"
percent: root.temperature
detail: root.temperature + "°C"
percent: stats.temperature
detail: stats.temperature + "°C"
}
}
}