disk: clean up
This commit is contained in:
parent
d8a3ae5fed
commit
4a414135ae
46
neofetch
46
neofetch
|
@ -3325,17 +3325,17 @@ END
|
||||||
}
|
}
|
||||||
|
|
||||||
get_disk() {
|
get_disk() {
|
||||||
type -p df &>/dev/null ||\
|
type -p df &>/dev/null ||
|
||||||
{ err "Disk requires 'df' to function. Install 'df' to get disk info."; return; }
|
{ err "Disk requires 'df' to function. Install 'df' to get disk info."; return; }
|
||||||
|
|
||||||
df_version="$(df --version 2>&1)"
|
df_version=$(df --version 2>&1)
|
||||||
|
|
||||||
case $df_version in
|
case $df_version in
|
||||||
*"IMitv"*) df_flags=(-P -g) ;; # AIX
|
*IMitv*) df_flags=(-P -g) ;; # AIX
|
||||||
*"befhikm"*) df_flags=(-P -k) ;; # IRIX
|
*befhikm*) df_flags=(-P -k) ;; # IRIX
|
||||||
*"hiklnP"*) df_flags=(-h) ;; # OpenBSD
|
*hiklnP*) df_flags=(-h) ;; # OpenBSD
|
||||||
|
|
||||||
*"Tracker"*) # Haiku
|
*Tracker*) # Haiku
|
||||||
err "Your version of df cannot be used due to the non-standard flags"
|
err "Your version of df cannot be used due to the non-standard flags"
|
||||||
return
|
return
|
||||||
;;
|
;;
|
||||||
|
@ -3349,7 +3349,7 @@ get_disk() {
|
||||||
unset "disks[0]"
|
unset "disks[0]"
|
||||||
|
|
||||||
# Stop here if 'df' fails to print disk info.
|
# Stop here if 'df' fails to print disk info.
|
||||||
[[ -z "${disks[*]}" ]] && {
|
[[ ${disks[*]} ]] || {
|
||||||
err "Disk: df failed to print the disks, make sure the disk_show array is set properly."
|
err "Disk: df failed to print the disks, make sure the disk_show array is set properly."
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -3357,10 +3357,10 @@ get_disk() {
|
||||||
for disk in "${disks[@]}"; do
|
for disk in "${disks[@]}"; do
|
||||||
# Create a second array and make each element split at whitespace this time.
|
# Create a second array and make each element split at whitespace this time.
|
||||||
IFS=" " read -ra disk_info <<< "$disk"
|
IFS=" " read -ra disk_info <<< "$disk"
|
||||||
disk_perc="${disk_info[4]/\%}"
|
disk_perc=${disk_info[4]/\%}
|
||||||
|
|
||||||
case $df_version in
|
case $df_version in
|
||||||
*"befhikm"*)
|
*befhikm*)
|
||||||
disk="$((disk_info[2]/1024/1024))G / $((disk_info[1]/1024/1024))G (${disk_perc}%)"
|
disk="$((disk_info[2]/1024/1024))G / $((disk_info[1]/1024/1024))G (${disk_perc}%)"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
@ -3369,35 +3369,33 @@ get_disk() {
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Subtitle.
|
|
||||||
case $disk_subtitle in
|
case $disk_subtitle in
|
||||||
"name")
|
name)
|
||||||
disk_sub="${disk_info[0]}"
|
disk_sub=${disk_info[0]}
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"dir")
|
dir)
|
||||||
disk_sub="${disk_info[5]/*\/}"
|
disk_sub=${disk_info[5]/*\/}
|
||||||
disk_sub="${disk_sub:-${disk_info[5]}}"
|
disk_sub=${disk_sub:-${disk_info[5]}}
|
||||||
;;
|
;;
|
||||||
|
|
||||||
*)
|
*)
|
||||||
disk_sub="${disk_info[5]}"
|
disk_sub=${disk_info[5]}
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Bar.
|
|
||||||
case $disk_display in
|
case $disk_display in
|
||||||
"bar") disk="$(bar "$disk_perc" "100")" ;;
|
bar) disk="$(bar "$disk_perc" "100")" ;;
|
||||||
"infobar") disk+=" $(bar "$disk_perc" "100")" ;;
|
infobar) disk+=" $(bar "$disk_perc" "100")" ;;
|
||||||
"barinfo") disk="$(bar "$disk_perc" "100")${info_color} $disk" ;;
|
barinfo) disk="$(bar "$disk_perc" "100")${info_color} $disk" ;;
|
||||||
"perc") disk="${disk_perc}% $(bar "$disk_perc" "100")" ;;
|
perc) disk="${disk_perc}% $(bar "$disk_perc" "100")" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Append '(disk mount point)' to the subtitle.
|
# Append '(disk mount point)' to the subtitle.
|
||||||
if [[ -z "$subtitle" ]]; then
|
if [[ "$subtitle" ]]; then
|
||||||
prin "${disk_sub}" "$disk"
|
prin "$subtitle ($disk_sub)" "$disk"
|
||||||
else
|
else
|
||||||
prin "${subtitle} (${disk_sub})" "$disk"
|
prin "$disk_sub" "$disk"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue