75 lines
2.1 KiB
Text
75 lines
2.1 KiB
Text
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
|
|
|
|
info "$(color 7)OS" distro
|
|
info "$(color 15)├─$(color 6) Kernel" kernel
|
|
info "$(color 15)├─$(color 6) Uptime" uptime
|
|
info "$(color 15)└─$(color 6) Packages" packages
|
|
|
|
prin
|
|
prin "$(color 7)PC" "@model@"
|
|
info "$(color 15)├─$(color 6) CPU" cpu
|
|
info "$(color 15)├─$(color 6) GPU" gpu
|
|
info "$(color 15)├─$(color 6) Resolution" resolution
|
|
info "$(color 15)└─$(color 6) Memory" memory
|
|
|
|
prin
|
|
prin "$(color 15)Disks"
|
|
info disk
|
|
info zpools
|
|
|
|
info cols
|
|
}
|
|
|
|
kernel_shorthand="off"
|
|
uptime_shorthand="off"
|
|
memory_percent="on"
|
|
memory_unit="gib"
|
|
separator=" ➜"
|
|
color_blocks="off"
|
|
|
|
# Disk
|
|
disk_show=('/' '/media/main' '/media/data' '/media/store')
|
|
|
|
# Image
|
|
image_backend="ascii"
|