refactor and add modules directory

This commit is contained in:
wt committed 2025-03-10 21:51:05 +07:00
1 parent b272840eae
commit 8f5ad70ed3
13 files changed
+209 -90

No files matched your search

+33
View File
@@ -0,0 +1,33 @@
import { Variable } from "astal";
import GTop from 'gi://GTop';
const computeStorage = (): string => {
try {
const currentFsUsage = new GTop.glibtop_fsusage();
GTop.glibtop_get_fsusage(currentFsUsage, '/');
const total = currentFsUsage.blocks * currentFsUsage.block_size;
const available = currentFsUsage.bavail * currentFsUsage.block_size;
const used = total - available;
const storagestring = " " + Math.floor(used / total * 100) + "%"
return storagestring
} catch (error) {
console.error('Error calculating RAM usage:', error);
return "";
}
};
export default function Storage() {
const storage_usage = Variable<string>("").poll(5000, () =>
computeStorage())
return <box className="storage">
<label
className="Storage"
onDestroy={() => storage_usage.drop()}
label={storage_usage()} />
</box>
}