nova-shell/modules/Disk.qml
2026-04-10 10:49:48 +02:00

38 lines
975 B
QML

import QtQuick
import Quickshell.Io
import "." as M
Text {
id: root
property int freePct: 0
property real totalTb: 0
Process {
id: proc
running: true
command: ["sh", "-c", "df -B1 --output=size,avail / | tail -1"]
stdout: StdioCollector {
onStreamFinished: {
const parts = text.trim().split(/\s+/).map(Number);
const size = parts[0], avail = parts[1];
if (size > 0) {
root.freePct = Math.round((avail / size) * 100);
root.totalTb = size / 1e12;
}
}
}
}
Timer {
interval: 30000
running: true
repeat: true
onTriggered: proc.running = true
}
text: " " + root.freePct + "% " + root.totalTb.toFixed(1)
color: M.Theme.base05
font.pixelSize: M.Theme.fontSize
font.family: M.Theme.fontFamily
verticalAlignment: Text.AlignVCenter
}