nova-shell/modules/Disk.qml
2026-04-11 12:08:06 +02:00

45 lines
1.1 KiB
QML

import QtQuick
import Quickshell.Io
import "." as M
Row {
id: root
spacing: 2
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
}
M.BarIcon {
icon: ""
anchors.verticalCenter: parent.verticalCenter
}
Text {
text: root.freePct + "% " + root.totalTb.toFixed(1)
color: M.Theme.base05
font.pixelSize: M.Theme.fontSize
font.family: M.Theme.fontFamily
verticalAlignment: Text.AlignVCenter
}
}