Disk: Add disk_show

This commit is contained in:
Dylan Araps 2017-01-06 18:53:26 +11:00
parent aed21c449c
commit 5b1f273dfc
1 changed files with 39 additions and 12 deletions

View File

@ -1622,20 +1622,32 @@ get_disk() {
*) df_flags=(-P -h) ;; *) df_flags=(-P -h) ;;
esac esac
# Get the info for "/". # Create an array called 'disks' where each element is a separate line from
disks=($(df "${df_flags[@]}" /)) || { err "Disk: 'df' exited with error code 1"; return; } # df's output. We then unset the first element which removes the column titles.
readarray disks < <(df "${df_flags[@]}" "${disk_show[@]:-/}") && unset 'disks[0]'
# Put it all together. # Stop here if 'df' fails to print disk info.
disk_perc="${disks[11]/'%'}" [[ -z "${disks[@]}" ]] && \
disk="${disks[9]/i} / ${disks[8]/i} (${disk_perc}%)" { err "Disk: df failed to print the disks, make sure the disk_show array is set properly."; return; }
# Bar. for disk in "${disks[@]}"; do
case "$disk_display" in # Create a second array and make each element split at whitespacw this time.
"bar") disk="$(bar "$disk_perc" "100")" ;; disk_info=($disk)
"infobar") disk+=" $(bar "$disk_perc" "100")" ;; disk_perc="${disk_info[4]/'%'}"
"barinfo") disk="$(bar "$disk_perc" "100") $disk" ;;
"perc") disk="${disk_perc}% $(bar "$disk_perc" "100")" ;; disk="${disk_info[2]/i} / ${disk_info[1]/i} (${disk_perc}%)"
esac
# Bar.
case "$disk_display" in
"bar") disk="$(bar "$disk_perc" "100")" ;;
"infobar") disk+=" $(bar "$disk_perc" "100")" ;;
"barinfo") disk="$(bar "$disk_perc" "100") $disk" ;;
"perc") disk="${disk_perc}% $(bar "$disk_perc" "100")" ;;
esac
# Append '(disk mount point)' to the subtitle.
prin "${subtitle} (${disk_info[5]})" "$disk"
done
} }
get_battery() { get_battery() {
@ -3531,6 +3543,10 @@ INFO:
--gtk3 on/off Enable/Disable gtk3 theme/font/icons output --gtk3 on/off Enable/Disable gtk3 theme/font/icons output
--shell_path on/off Enable/Disable showing \$SHELL path --shell_path on/off Enable/Disable showing \$SHELL path
--shell_version on/off Enable/Disable showing \$SHELL version --shell_version on/off Enable/Disable showing \$SHELL version
--disk_show value Which disks to display.
Takes: '/', '/dev/sdXX', '/path/to/mount point'
NOTE: Multiple values can be given. (--disk_show '/' '/dev/sdc1')
--ip_host url URL to query for public IP --ip_host url URL to query for public IP
--song_shorthand on/off Print the Artist/Title on separate lines --song_shorthand on/off Print the Artist/Title on separate lines
--install_time on/off Enable/Disable showing the time in Install Date output. --install_time on/off Enable/Disable showing the time in Install Date output.
@ -3695,6 +3711,17 @@ get_args() {
[[ "$cpu_temp" == "on" ]] && cpu_temp="C" [[ "$cpu_temp" == "on" ]] && cpu_temp="C"
;; ;;
"--disk_show")
unset disk_show
for arg in "$@"; do
case "$arg" in
"--disk_show") ;;
"-"*) break ;;
*) disk_show+=($arg)
esac
done
;;
"--disable") "--disable")
for func in "$@"; do for func in "$@"; do
case "$func" in case "$func" in