From f24f7ad9b7f7854169ca76779bb251be1d2ca4c1 Mon Sep 17 00:00:00 2001 From: Dylan Date: Thu, 3 Mar 2016 11:00:47 +1100 Subject: [PATCH] Added progress bar support to memory output --- 1.4.md | 4 ++++ README.md | 1 + config/config | 5 ++++- neofetch | 13 ++++++++++--- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/1.4.md b/1.4.md index 813905f3..2df717c5 100644 --- a/1.4.md +++ b/1.4.md @@ -20,6 +20,10 @@ will be drawn with. - Added `--cpu_usage_bar` and `$cpu_usage_bar` to enable/disable displaying a progress
bar in the output. +**Memory**
+- Added `--memory_bar` and `$memory_bar` to enable/disable displaying a progress bar in
+the output. + **Battery**
- Added support for NetBSD diff --git a/README.md b/README.md index 004068ec..8be3bfa3 100644 --- a/README.md +++ b/README.md @@ -286,6 +286,7 @@ alias fetch2="fetch \ --progress_colors num num Colors to make the progress bar. Set in this order: elapsed, total --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: diff --git a/config/config b/config/config index f57730c8..244e353f 100644 --- a/config/config +++ b/config/config @@ -234,8 +234,11 @@ progress_length="15" progress_color_elapsed="6" 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" +memory_bar="on" # }}} diff --git a/neofetch b/neofetch index a9255e22..a39d21ba 100755 --- a/neofetch +++ b/neofetch @@ -256,8 +256,11 @@ progress_length="15" progress_color_elapsed="6" 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" +memory_bar="on" # }}} @@ -1071,6 +1074,9 @@ getmemory () { memory="Unknown" ;; esac + + [ "$memory_bar" == "on" ] && \ + memory+=" $(bar "$((memused / 100000))" "$((memtotal / 100000))")" } # }}} @@ -1600,7 +1606,7 @@ getcpu_usage () { cpu_usage="${cpu_usage/\.*}%" [ "$cpu_usage_bar" == "on" ] && \ - cpu_usage+=" $(bar "${cpu_usage/'%'}")" + cpu_usage+=" $(bar "${cpu_usage/'%'}" 100)" } @@ -2269,7 +2275,7 @@ esac bar() { # Get the values percent="$1" - elapsed=$((percent * progress_length / 100)) + elapsed=$((percent * progress_length / $2)) # Create the bar with spaces 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: elapsed, total --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: