From c0c709ed1054342f3d1722b5b3fe5a1c12f425d9 Mon Sep 17 00:00:00 2001 From: Infinidoge Date: Mon, 18 Nov 2024 11:24:31 -0500 Subject: [PATCH] Infini-DL360/ssh: add zpools to neofetch --- hosts/Infini-DL360/neofetch.conf | 42 +++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/hosts/Infini-DL360/neofetch.conf b/hosts/Infini-DL360/neofetch.conf index 9f22c75..f93d501 100644 --- a/hosts/Infini-DL360/neofetch.conf +++ b/hosts/Infini-DL360/neofetch.conf @@ -1,3 +1,42 @@ +get_zpools() { + type -p zpool &>/dev/null || + { err "Collecting zpool stats requires 'zpool' to function. Install 'zpool' to get disk info."; return; } + + IFS=$'\n' read -d "" -ra pools <<< "$(zpool list -H -o name,allocated,size,capacity)" + + # Stop here if 'zpool' fails. + [[ ${pools[*]} ]] || { + err "Disk: zpool failed to print the ZFS pools." + return + } + + for pool in "${pools[@]}"; do + # Create a second array and make each element split at whitespace this time. + IFS=$'\t' read -ra pool_info <<< "$pool" + + case "${disk_percent}" in + off) disk_perc= ;; + *) disk_perc=${pool_info[3]/\%} + esac + disk="${pool_info[1]} / ${pool_info[2]}${disk_perc:+ (${disk_perc}%)}" + disk_sub="${pool_info[0]}" + + case "${disk_display}" in + bar) disk="$(bar "$disk_perc" "100")" ;; + infobar) disk+=" $(bar "$disk_perc" "100")" ;; + barinfo) disk="$(bar "$disk_perc" "100")${info_color} $disk" ;; + perc) disk="${disk_perc}% $(bar "$disk_perc" "100")" ;; + esac + + # Append '(disk mount point)' to the subtitle. + if [[ "$subtitle" ]]; then + prin "$subtitle${disk_sub:+ ($disk_sub)}" "$disk" + else + prin "$disk_sub" "$disk" + fi + done +} + print_info() { info title info underline @@ -17,6 +56,7 @@ print_info() { prin prin "$(color 15)Disks" info disk + info zpools info cols } @@ -29,7 +69,7 @@ separator=" ➜" color_blocks="off" # Disk -disk_show=('/' '/media/main' '/media/data') +disk_show=('/' '/media/main' '/media/data' '/media/store') # Image image_backend="ascii"