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,12 +1622,20 @@ 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; }
for disk in "${disks[@]}"; do
# Create a second array and make each element split at whitespacw this time.
disk_info=($disk)
disk_perc="${disk_info[4]/'%'}"
disk="${disk_info[2]/i} / ${disk_info[1]/i} (${disk_perc}%)"
# Bar. # Bar.
case "$disk_display" in case "$disk_display" in
@ -1636,6 +1644,10 @@ get_disk() {
"barinfo") disk="$(bar "$disk_perc" "100") $disk" ;; "barinfo") disk="$(bar "$disk_perc" "100") $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.
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