Commit 49a96948 authored by Dylan Araps's avatar Dylan Araps

Disk: Use '-h'

parent 17e9fa77
...@@ -1540,31 +1540,34 @@ get_disk() { ...@@ -1540,31 +1540,34 @@ get_disk() {
type -p df >/dev/null 2>&1 || { err "Disk requires 'df' to function. Install 'df' to get disk info."; return; } type -p df >/dev/null 2>&1 || { err "Disk requires 'df' to function. Install 'df' to get disk info."; return; }
# Get the info for / # Get the info for /
disks=($(df /)) disks=($(df -h /))
# Split the info # Split the info
disk_used="$((disks[9] / 1024 / 1024))GB" disk_used="${disks[9]}"
disk_total="$((disks[8] / 1024 / 1024))GB" disk_total="${disks[8]}"
disk_total_per="(${disks[11]})"
# Handle TB values # Put it all together
(( "${#disk_used}" == 6 )) && disk_used="${disk_used:0:1}.${disk_used:1:1}TB" disk="${disk_used} / ${disk_total} ${disk_total_per}"
(( "${#disk_total}" == 6 )) && disk_total="${disk_total:0:1}.${disk_total:1:1}TB"
# Get the filesystem type # Convert Terabytes to Gigabytes.
disk_type="[$(awk '$2 == "/" {printf $3; exit}' /etc/fstab)]" if [[ "$disk_display" != "off" ]]; then
disk_used="${disk_used/\.}"
disk_total="${disk_total/\.}"
# Get the usage percentage [[ "${disk_used: -1}" == "T" ]] && \
disk_total_per="(${disks[11]})" disk_used="$((${disk_used/T} * 100))"
# Put it all together [[ "${disk_total: -1}" == "T" ]] && \
disk="${disk_used} / ${disk_total} ${disk_total_per} ${disk_type}" disk_total="$((${disk_total/T} * 100))"
fi
# Bar # Bar
case "$disk_display" in case "$disk_display" in
"bar") disk="$(bar "${disk_used//[a-z]}" "${disk_total//[a-z]}")" ;; "bar") disk="$(bar "${disk_used/'.'*}" "${disk_total/'.'*}")" ;;
"infobar") disk+=" $(bar "${disk_used//[a-z]}" "${disk_total//[a-z]}")" ;; "infobar") disk+=" $(bar "${disk_used/'.'*}" "${disk_total/'.'*}")" ;;
"barinfo") disk="$(bar "${disk_used//[a-z]}" "${disk_total//[a-z]}") $disk" ;; "barinfo") disk="$(bar "${disk_used/'.'*}" "${disk_total/'.'*}") $disk" ;;
"perc") disk="$disk_total_per $(bar "${disk_used//[a-z]}" "${disk_total//[a-z]}")" ;; "perc") disk="$disk_total_per $(bar "${disk_used/'.'*}" "${disk_total/'.'*}")" ;;
esac esac
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment