refactor: add SystemStats singleton + nova-stats daemon for cpu/mem polling
This commit is contained in:
parent
71a843e0f3
commit
136ff53cb5
13 changed files with 371 additions and 196 deletions
|
|
@ -1,5 +1,4 @@
|
|||
import QtQuick
|
||||
import Quickshell.Io
|
||||
import "." as M
|
||||
|
||||
M.BarSection {
|
||||
|
|
@ -7,46 +6,8 @@ M.BarSection {
|
|||
spacing: Math.max(1, M.Theme.moduleSpacing - 2)
|
||||
tooltip: ""
|
||||
|
||||
property var _mounts: []
|
||||
property int _rootPct: 0
|
||||
|
||||
Process {
|
||||
id: proc
|
||||
running: true
|
||||
command: ["sh", "-c", "df -x tmpfs -x devtmpfs -x squashfs -x efivarfs -x overlay -B1 --output=target,size,used 2>/dev/null | awk 'NR>1 && $2+0>0 {print $1\"|\"$2\"|\"$3}'"]
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: {
|
||||
const lines = text.trim().split("\n").filter(l => l);
|
||||
const mounts = [];
|
||||
for (const line of lines) {
|
||||
const parts = line.split("|");
|
||||
if (parts.length < 3)
|
||||
continue;
|
||||
const total = parseInt(parts[1]);
|
||||
const used = parseInt(parts[2]);
|
||||
if (total <= 0)
|
||||
continue;
|
||||
mounts.push({
|
||||
"target": parts[0],
|
||||
"pct": Math.round(used / total * 100),
|
||||
"usedBytes": used,
|
||||
"totalBytes": total
|
||||
});
|
||||
}
|
||||
root._mounts = mounts;
|
||||
const rm = mounts.find(m => m.target === "/");
|
||||
if (rm)
|
||||
root._rootPct = rm.pct;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
interval: M.Modules.disk.interval || 30000
|
||||
running: true
|
||||
repeat: true
|
||||
onTriggered: proc.running = true
|
||||
}
|
||||
property var _mounts: M.SystemStats.diskMounts
|
||||
property int _rootPct: M.SystemStats.diskRootPct
|
||||
|
||||
function _fmt(bytes) {
|
||||
if (bytes >= 1e12)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue