import QtQuick import Quickshell.Io import "." as M M.BarSection { id: root spacing: 2 tooltip: "Memory: " + root.percent + "% used" property int percent: 0 FileView { id: meminfo path: "/proc/meminfo" onLoaded: { const m = {}; text().split("\n").forEach(l => { const [k, v] = l.split(":"); if (v) m[k.trim()] = parseInt(v.trim()); }); const total = m.MemTotal; const avail = m.MemAvailable; if (total > 0) root.percent = Math.round(((total - avail) / total) * 100); } } Timer { interval: 2000 running: true repeat: true onTriggered: meminfo.reload() } M.BarIcon { icon: "\uEFC5" anchors.verticalCenter: parent.verticalCenter } Text { text: root.percent + "%" color: M.Theme.base05 font.pixelSize: M.Theme.fontSize font.family: M.Theme.fontFamily verticalAlignment: Text.AlignVCenter } }