46 lines
1.2 KiB
QML
46 lines
1.2 KiB
QML
import QtQuick
|
|
import Quickshell.Io
|
|
import "." as M
|
|
|
|
M.BarSection {
|
|
id: root
|
|
spacing: Math.max(1, M.Theme.moduleSpacing - 2)
|
|
tooltip: root.freePct + "% free of " + root.totalTb.toFixed(1) + " TB"
|
|
|
|
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: M.Modules.disk.interval || 30000
|
|
running: true
|
|
repeat: true
|
|
onTriggered: proc.running = true
|
|
}
|
|
|
|
M.BarIcon {
|
|
icon: "\uF0C9"
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
}
|
|
M.BarLabel {
|
|
label: root.freePct + "% " + root.totalTb.toFixed(1)
|
|
minText: "100% 9.9"
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
}
|
|
}
|