reorganize repo: move shell sources into shell/, test scripts into test/
This commit is contained in:
parent
344c1f8512
commit
d6cd2f173a
60 changed files with 2 additions and 2 deletions
|
|
@ -1,43 +0,0 @@
|
|||
import QtQuick
|
||||
import Quickshell.Io
|
||||
|
||||
QtObject {
|
||||
id: root
|
||||
|
||||
property string sortBy: "cpu" // "cpu" or "mem"
|
||||
property int maxItems: 8
|
||||
property bool active: false
|
||||
|
||||
property var processes: []
|
||||
|
||||
property Process _proc: Process {
|
||||
command: ["sh", "-c", "ps --no-headers -eo pid,pcpu,pmem,comm --sort=-%" + root.sortBy + " | head -" + root.maxItems]
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: {
|
||||
const rows = [];
|
||||
for (const line of text.trim().split("\n")) {
|
||||
if (!line)
|
||||
continue;
|
||||
const p = line.trim().split(/\s+/);
|
||||
if (p.length < 4)
|
||||
continue;
|
||||
rows.push({
|
||||
"pid": parseInt(p[0]),
|
||||
"cpu": parseFloat(p[1]),
|
||||
"mem": parseFloat(p[2]),
|
||||
"cmd": p.slice(3).join(" ")
|
||||
});
|
||||
}
|
||||
root.processes = rows;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
property Timer _timer: Timer {
|
||||
interval: 2000
|
||||
running: root.active
|
||||
repeat: true
|
||||
triggeredOnStart: true
|
||||
onTriggered: root._proc.running = true
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue