diff options
| author | Caroline Larimore <caroline@larimo.re> | 2024-09-17 21:37:33 -0700 |
|---|---|---|
| committer | Caroline Larimore <caroline@larimo.re> | 2024-09-17 21:37:33 -0700 |
| commit | 6bc6e37af5b21b0356d0e008f83eee5378fc8b43 (patch) | |
| tree | 0fd4e2fdf9ddd1937b3a02de57d11e4ff1ade6fc /roles/home/desktop/eww/panels/fs.yuck | |
| parent | 485dc4b641f6b07def1bfa28c7c3ab83e764f29e (diff) | |
home: desktop: update eww widgets
Diffstat (limited to 'roles/home/desktop/eww/panels/fs.yuck')
| -rw-r--r-- | roles/home/desktop/eww/panels/fs.yuck | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/roles/home/desktop/eww/panels/fs.yuck b/roles/home/desktop/eww/panels/fs.yuck new file mode 100644 index 0000000..54bbd46 --- /dev/null +++ b/roles/home/desktop/eww/panels/fs.yuck @@ -0,0 +1,74 @@ +(defwidget disks [] + (box :class "panel disks" + :orientation "h" + :spacing 8 + :space-evenly false + :height {100+16} + + (disk :mount "total" + :zfs true + :name "zpool" + ) + + (disk :mount "/mnt/4tb" + :name "4tb" + ) + (disk :mount "/mnt/ssd" + :name "ssd" + ) + ) +) + +(defwidget zfs [] + (box :class "panel zfs" + :orientation "v" + :spacing 8 + :space-evenly false + :hexpand true + + (label :halign "start" :markup "<b>ZFS Volumes</b>") + + (zvol :mount "/nix") + (zvol :mount "/persist") + + (zvol :class "faint" + :mount "/home" + ) + + (zvol :class "faint" + :mount "/" + ) + + (zvol :class "total" + :mount "total" + :name "Total" + ) + ) +) + +(defwidget disk [mount ?name ?zfs] + (meter + :value { + (zfs == true ? zpool : disks)[mount].used / ((zfs == true ? zpool : disks)[mount].used + (zfs == true ? zpool : disks)[mount].free) * 100} + :label {name != "" ? name : mount} + + {round((zfs == true ? zpool : disks)[mount].used/1024/1024, 0) + " GiB"} + ) +) + +(defwidget zvol [mount ?name ?class] + (stat :class {class} + :key {name != "" ? name : mount} + :value {round(zpool[mount].used/1024/1024, 2) + " GiB"} + ) +) + +(defpoll disks + :interval "10s" + `df -x fuse -x tmpfs -x efivarfs -x devtmpfs -x zfs | tail -n +2 | awk '{ printf "%s free %d\\n%s used %d\\n", $6, $4, $6, $3 }' | xargs printf '{"%s": {"%s": %d}}\\n' | jq -scaM 'map(to_entries) | flatten | group_by(.key) | map({"\\(.[0].key)": map(.value | to_entries) | flatten | from_entries}) | add'` +) + +(defpoll zpool + :interval "10s" + `df -t zfs --total | tail -n +2 | awk '{ printf "%s free %d\\n%s used %d\\n", $6, $4, $6, $3 }' | xargs printf '{"%s": {"%s": %d}}\\n' | jq -scaM 'map(to_entries) | flatten | group_by(.key) | map({"\\(.[0].key)": map(.value | to_entries) | flatten | from_entries}) | add | .total = ."-" | del(."-") | .total.free = ."/zpool".free'` +) |