Removed useless subdirectory, changed to dolphin
This commit is contained in:
parent
2e2d683c62
commit
f20db908ca
10 changed files with 4 additions and 4 deletions
52
quickshell/modules/Cpu.qml
Normal file
52
quickshell/modules/Cpu.qml
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import QtQuick
|
||||
import qs
|
||||
|
||||
Rectangle {
|
||||
id: root
|
||||
property real lastCpuTotal: 0.0
|
||||
property real lastCpuIdle: 0.0
|
||||
property real cpuUsage: 0.0
|
||||
color: Appearance.colAppBg
|
||||
implicitHeight: Appearance.appletRadHeight
|
||||
implicitWidth: cpuText.width + 25
|
||||
radius: Appearance.appletRadHeight
|
||||
Process {
|
||||
id: cpuProc
|
||||
command: ["sh", "-c", "head -1 /proc/stat"]
|
||||
property double cpuUsage
|
||||
stdout: SplitParser {
|
||||
onRead: data => {
|
||||
if (!data) {
|
||||
return;
|
||||
}
|
||||
else {
|
||||
var p = data.trim().split(/\s+/);
|
||||
var idle = parseInt(p[4]) + parseInt(p[5]);
|
||||
var total = p.slice(1, 8).reduce((a, b) => a + parseInt(b), 0);
|
||||
root.cpuUsage = Math.round(100 * (1 - (idle - root.lastCpuIdle) / (total - root.lastCpuTotal)));
|
||||
root.lastCpuTotal = total;
|
||||
root.lastCpuIdle = idle;
|
||||
}
|
||||
}
|
||||
}
|
||||
Component.onCompleted: running = true
|
||||
}
|
||||
Timer {
|
||||
id: cpuProcRestarter
|
||||
interval: 2000
|
||||
repeat: true
|
||||
running: true
|
||||
onTriggered: cpuProc.running = true
|
||||
}
|
||||
Text {
|
||||
font.family: Appearance.font
|
||||
font.pixelSize: Appearance.fontSize
|
||||
font.bold: true
|
||||
color: Appearance.colFg
|
||||
id: cpuText
|
||||
anchors.centerIn: parent
|
||||
text: "CPU: " + root.cpuUsage + "%"
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue