Infini-DL360/ssh: add zpools to neofetch
This commit is contained in:
parent
6a6cfe89b4
commit
c0c709ed10
1 changed files with 41 additions and 1 deletions
|
@ -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() {
|
print_info() {
|
||||||
info title
|
info title
|
||||||
info underline
|
info underline
|
||||||
|
@ -17,6 +56,7 @@ print_info() {
|
||||||
prin
|
prin
|
||||||
prin "$(color 15)Disks"
|
prin "$(color 15)Disks"
|
||||||
info disk
|
info disk
|
||||||
|
info zpools
|
||||||
|
|
||||||
info cols
|
info cols
|
||||||
}
|
}
|
||||||
|
@ -29,7 +69,7 @@ separator=" ➜"
|
||||||
color_blocks="off"
|
color_blocks="off"
|
||||||
|
|
||||||
# Disk
|
# Disk
|
||||||
disk_show=('/' '/media/main' '/media/data')
|
disk_show=('/' '/media/main' '/media/data' '/media/store')
|
||||||
|
|
||||||
# Image
|
# Image
|
||||||
image_backend="ascii"
|
image_backend="ascii"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue