nova-shell/shell/modules/DiskModule.qml

51 lines
1.4 KiB
QML

import QtQuick
import Quickshell
import "." as M
import "../services" as S
import "../applets" as C
M.BarModule {
id: root
spacing: Math.max(1, S.Theme.moduleSpacing - 2)
tooltip: "Disk: " + _rootPct + "% used"
property var _mounts: S.SystemStats.diskMounts
property int _rootPct: S.SystemStats.diskRootPct
readonly property int _warnThreshold: S.Modules.disk.warnThreshold ?? 85
readonly property bool _anyWarn: {
for (const m of _mounts)
if (m.pct >= _warnThreshold)
return true;
return false;
}
M.BarIcon {
icon: "\uF0C9"
color: root._anyWarn ? S.Theme.base09 : root.accentColor
anchors.verticalCenter: parent.verticalCenter
}
M.BarLabel {
label: root._rootPct + "%"
minText: "100%"
color: root._anyWarn ? S.Theme.base09 : root.accentColor
anchors.verticalCenter: parent.verticalCenter
}
M.HoverPanel {
id: hoverPanel
showPanel: root._showPanel
screen: QsWindow.window?.screen ?? null
anchorItem: root
accentColor: root.accentColor
panelNamespace: "nova-disk"
panelTitle: "Disk"
contentWidth: 260
onDismissed: root.dismissPanel()
C.DiskApplet {
width: hoverPanel.contentWidth
mounts: root._mounts
accentColor: root.accentColor
}
}
}