initial commit
This commit is contained in:
commit
9fde6d4fc6
27 changed files with 1110 additions and 0 deletions
36
modules/Memory.qml
Normal file
36
modules/Memory.qml
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
import QtQuick
|
||||
import Quickshell.Io
|
||||
import "." as M
|
||||
|
||||
Text {
|
||||
id: root
|
||||
|
||||
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()
|
||||
}
|
||||
|
||||
text: " " + root.percent + "%"
|
||||
color: M.Theme.base05
|
||||
font.pixelSize: M.Theme.fontSize
|
||||
font.family: M.Theme.fontFamily
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue