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