diff options
| -rw-r--r-- | README.md | 12 | ||||
| -rw-r--r-- | services/SystemUsage.qml | 40 |
2 files changed, 42 insertions, 10 deletions
@@ -9,6 +9,18 @@ </div> +> [!WARNING] +> I am currently working on a complete overhaul for everything but the shell which should fix most issues with installation. +> As such, I will not be working on the shell until the overhaul is finished. I will still try to answer issues, however other +> than minor issues, I will most likely not be able to fix them (same goes for feature requests). PRs are still welcome though! +> +> Some breaking changes: +> - Rename the `scripts` repo -> `cli` +> - Rename the `hypr` repo -> `caelestia` (this will be the main repo after the change) +> - Merge all other repos (except this and `cli`) into `caelestia` +> - Installation for the `shell` and `cli` will be done via AUR packages; `caelestia` will have a meta package and an install script (should fix most installation issues) +> - Overhaul the scheme system (should fix a few bugs with that and make it cleaner in general) + https://github.com/user-attachments/assets/0840f496-575c-4ca6-83a8-87bb01a85c5f ## Components diff --git a/services/SystemUsage.qml b/services/SystemUsage.qml index 1de0c57..ef953f1 100644 --- a/services/SystemUsage.qml +++ b/services/SystemUsage.qml @@ -97,19 +97,39 @@ Singleton { id: storage running: true - command: ["sh", "-c", "df | grep '^/dev/' | awk '{print $3, $4}'"] + command: ["sh", "-c", "df | grep '^/dev/' | awk '{print $1, $3, $4}'"] stdout: SplitParser { splitMarker: "" onRead: data => { - let used = 0; - let avail = 0; - for (const line of data.trim().split("\n")) { - const [u, a] = line.split(" "); - used += parseInt(u, 10); - avail += parseInt(a, 10); - } - root.storageUsed = used; - root.storageTotal = used + avail; + const deviceMap = new Map(); + + for (const line of data.trim().split("\n")) { + if (line.trim() === "") continue; + + const parts = line.trim().split(/\s+/); + if (parts.length >= 3) { + const device = parts[0]; + const used = parseInt(parts[1], 10) || 0; + const avail = parseInt(parts[2], 10) || 0; + + // only keep the entry with the largest total space for each device + if (!deviceMap.has(device) || + (used + avail) > (deviceMap.get(device).used + deviceMap.get(device).avail)) { + deviceMap.set(device, { used: used, avail: avail }); + } + } + } + + let totalUsed = 0; + let totalAvail = 0; + + for (const [device, stats] of deviceMap) { + totalUsed += stats.used; + totalAvail += stats.avail; + } + + root.storageUsed = totalUsed; + root.storageTotal = totalUsed + totalAvail; } } } |