Various progress bar fixes

This commit is contained in:
Dylan 2016-03-13 08:37:33 +11:00
parent 77cd07b7cb
commit 6485476ae7
2 changed files with 32 additions and 54 deletions

View File

@ -234,26 +234,21 @@ progress_length="15"
progress_color_elapsed="6" progress_color_elapsed="6"
progress_color_total="8" progress_color_total="8"
# Enable/Disable progress bars # Customize how the info is displayed.
# --cpu_usage_bar on/off # bar: Only the progress bar is displayed.
# --memory_bar on/off # infobar: The bar is displayed after the info.
# --battery_bar on/off # barinfo: The bar is displayed before the info.
# --disk_bar on/off # off: Only the info is displayed.
cpu_usage_bar="off" #
memory_bar="off" # --cpu_displau bar/infobar/barinfo/off
battery_bar="off" # --memory_display bar/infobar/barinfo/off
disk_bar="off" # --battery_display bar/infobar/barinfo/off
# --disk_display bar/infobar/barinfo/off
cpu_display="off"
memory_display="off"
battery_display="off"
disk_display="off"
# Enable/Disable showing just the bar on its own.
# Set this to 'off' to only show the progress bar.
# --cpu_usage_info on/off
# --memory_info on/off
# --battery_info on/off
# --disk_info on/off
cpu_usage_info="on"
memory_info="on"
battery_info="on"
disk_info="on"
# }}} # }}}

View File

@ -262,10 +262,17 @@ progress_length="15"
progress_color_elapsed="6" progress_color_elapsed="6"
progress_color_total="8" progress_color_total="8"
# Enable/Disable progress bars # Customize how the info is displayed.
# --memory_bar bar/infobar/barinfo/off # bar: Only the progress bar is displayed.
# --battery_bar bar/infobar/barinfo/off # infobar: The bar is displayed after the info.
# --disk_bar bar/infobar/barinfo/off # barinfo: The bar is displayed before the info.
# off: Only the info is displayed.
#
# --cpu_displau bar/infobar/barinfo/off
# --memory_display bar/infobar/barinfo/off
# --battery_display bar/infobar/barinfo/off
# --disk_display bar/infobar/barinfo/off
cpu_display="off"
memory_display="off" memory_display="off"
battery_display="off" battery_display="off"
disk_display="off" disk_display="off"
@ -899,19 +906,17 @@ getcpu () {
esac esac
# Add CPU info bar # Add CPU info bar
prin "${subtitle}: ${cpu}" prin "${subtitle}: ${cpu}"
cpu_usage="$(ps aux | awk 'BEGIN { sum = 0 } { sum += $3 }; END { print sum }')" cpu_usage="$(ps aux | awk 'BEGIN { sum = 0 } { sum += $3 }; END { print sum }')"
cpu_usage="${cpu_usage/\.*}%" cpu_usage="${cpu_usage/\.*}%"
case "$cpu_display" in case "$cpu_display" in
"info") prin "CPU Usage: ${cpu_usage}" ;; "info") prin "${subtitle} Usage: ${cpu_usage}" ;;
"bar") prin "CPU Usage: $(bar "${cpu_usage/'%'}" 100)" ;; "bar") prin "${subtitle} Usage: $(bar "${cpu_usage/'%'}" 100)" ;;
"infobar") prin "CPU Usage: ${cpu_usage} $(bar "${cpu_usage/'%'}" 100)" ;; "infobar") prin "${subtitle} Usage: ${cpu_usage} $(bar "${cpu_usage/'%'}" 100)" ;;
"barinfo") prin "CPU Usage: $(bar "${cpu_usage/'%'}" 100) ${cpu_usage}" ;; "barinfo") prin "${subtitle} Usage: $(bar "${cpu_usage/'%'}" 100) ${cpu_usage}" ;;
esac esac
unset cpu unset cpu
} }
@ -1470,16 +1475,11 @@ getbattery () {
else else
if [ "${#batteries[@]}" -gt 1 ]; then if [ "${#batteries[@]}" -gt 1 ]; then
unset battery
# Print each battery on a separate line. # Print each battery on a separate line.
for bat in "${batteries[@]}"; do for bat in "${batteries[@]}"; do
battery="${title}${index}: ${bat}%" prin "${title}${index}: ${bat}%"
[ "$battery_bar" == "on" ] && \
battery+=" $(bar $bat 100)"
prin "$battery"
unset battery
index=$((index + 1))
done done
return return
fi fi
@ -1669,23 +1669,6 @@ getcols () {
fi fi
} }
# }}}
# CPU Usage {{{
getcpu_usage () {
cpu_usage="$(ps aux | awk 'BEGIN { sum = 0 } { sum += $3 }; END { print sum }')"
cpu_usage="${cpu_usage/\.*}%"
if [ "$cpu_usage_bar" == "on" ]; then
case "$cpu_usage_info" in
"off") cpu_usage="$(bar "${cpu_usage/'%'}" 100)" ;;
*) cpu_usage+=" $(bar "${cpu_usage/'%'}" 100)" ;;
esac
fi
}
# }}} # }}}
# }}} # }}}