a BUNCH of qml which I havent reviewed yet

This commit is contained in:
2026-10-23 16:19:22 -06:00
parent 7a57f3a0d2
commit 0d297296ca
16 changed files with 921 additions and 0 deletions
+36
View File
@@ -0,0 +1,36 @@
import QtQuick
// polybar 'internal/cpu'; silent until cpu usage is high
BarLabel {
id: cpu
property int warnPercentage: 79
property real lastIdle: 0
property real lastTotal: 0
color: Colors.alert
text: ""
PollingCommand {
interval: 3000
command: ["head", "-n1", "/proc/stat"]
onOutput: output => {
const fields = output.trim().split(/\s+/).slice(1).map(Number)
const idle = fields[3] + fields[4] // idle + iowait
const total = fields.reduce((sum, value) => sum + value, 0)
const deltaTotal = total - cpu.lastTotal
const used = cpu.lastTotal > 0 && deltaTotal > 0
? Math.round((1 - (idle - cpu.lastIdle) / deltaTotal) * 100)
: 0
cpu.lastIdle = idle
cpu.lastTotal = total
cpu.text = used >= cpu.warnPercentage
? `CPU${String(used).padStart(2)}%`
: ""
}
}
}