Added progress bar support to memory output

This commit is contained in:
Dylan 2016-03-03 11:00:47 +11:00
parent 639641a159
commit f24f7ad9b7
4 changed files with 19 additions and 4 deletions

4
1.4.md
View File

@ -20,6 +20,10 @@ will be drawn with.
- Added `--cpu_usage_bar` and `$cpu_usage_bar` to enable/disable displaying a progress<br \> - Added `--cpu_usage_bar` and `$cpu_usage_bar` to enable/disable displaying a progress<br \>
bar in the output. bar in the output.
**Memory**<br \>
- Added `--memory_bar` and `$memory_bar` to enable/disable displaying a progress bar in<br \>
the output.
**Battery**<br \> **Battery**<br \>
- Added support for NetBSD - Added support for NetBSD

View File

@ -286,6 +286,7 @@ alias fetch2="fetch \
--progress_colors num num Colors to make the progress bar. Set in this order: --progress_colors num num Colors to make the progress bar. Set in this order:
elapsed, total elapsed, total
--cpu_usage_bar on/off Whether or not to print a progress bar for cpu usage. --cpu_usage_bar on/off Whether or not to print a progress bar for cpu usage.
--memory_bar on/off Whether or not to print a progress bar for memory usage.
Image: Image:

View File

@ -234,8 +234,11 @@ progress_length="15"
progress_color_elapsed="6" progress_color_elapsed="6"
progress_color_total="8" progress_color_total="8"
# Cpu Usage progress bar # Enable/Disable progress bars
# --cpu_usage_bar on/off
# --memory_bar on/off
cpu_usage_bar="on" cpu_usage_bar="on"
memory_bar="on"
# }}} # }}}

View File

@ -256,8 +256,11 @@ progress_length="15"
progress_color_elapsed="6" progress_color_elapsed="6"
progress_color_total="8" progress_color_total="8"
# Cpu Usage progress bar # Enable/Disable progress bars
# --cpu_usage_bar on/off
# --memory_bar on/off
cpu_usage_bar="on" cpu_usage_bar="on"
memory_bar="on"
# }}} # }}}
@ -1071,6 +1074,9 @@ getmemory () {
memory="Unknown" memory="Unknown"
;; ;;
esac esac
[ "$memory_bar" == "on" ] && \
memory+=" $(bar "$((memused / 100000))" "$((memtotal / 100000))")"
} }
# }}} # }}}
@ -1600,7 +1606,7 @@ getcpu_usage () {
cpu_usage="${cpu_usage/\.*}%" cpu_usage="${cpu_usage/\.*}%"
[ "$cpu_usage_bar" == "on" ] && \ [ "$cpu_usage_bar" == "on" ] && \
cpu_usage+=" $(bar "${cpu_usage/'%'}")" cpu_usage+=" $(bar "${cpu_usage/'%'}" 100)"
} }
@ -2269,7 +2275,7 @@ esac
bar() { bar() {
# Get the values # Get the values
percent="$1" percent="$1"
elapsed=$((percent * progress_length / 100)) elapsed=$((percent * progress_length / $2))
# Create the bar with spaces # Create the bar with spaces
prog=$(printf %"$elapsed"s) prog=$(printf %"$elapsed"s)
@ -2345,6 +2351,7 @@ usage () { cat << EOF
--progress_colors num num Colors to make the progress bar. Set in this order: --progress_colors num num Colors to make the progress bar. Set in this order:
elapsed, total elapsed, total
--cpu_usage_bar on/off Whether or not to print a progress bar for cpu usage. --cpu_usage_bar on/off Whether or not to print a progress bar for cpu usage.
--memory_bar on/off Whether or not to print a progress bar for memory usage.
Image: Image: