From ba2001cc64aaad4a53dcb378cb42a099d51b1b5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C2=A9TriMoon=E2=84=A2?= Date: Mon, 31 Oct 2022 13:18:21 +0300 Subject: [PATCH 1/7] Update neofetch Added `tib` to usage output of `-memory_unit`. --- neofetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neofetch b/neofetch index 99bb5b48..1ddf7f38 100755 --- a/neofetch +++ b/neofetch @@ -5087,7 +5087,7 @@ INFO: --song_format format Print the song data in a specific format (see config file). --song_shorthand on/off Print the Artist/Album/Title on separate lines. --memory_percent on/off Display memory percentage. - --memory_unit kib/mib/gib Memory output unit. + --memory_unit (k/m/g/t)ib Memory output unit. --music_player player-name Manually specify a player to use. Available values are listed in the config file From a52c49380d2d0606442e093bdb7454cea0ca7934 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C2=A9TriMoon=E2=84=A2?= Date: Mon, 31 Oct 2022 13:52:51 +0300 Subject: [PATCH 2/7] Update neofetch Added `--memory_precision` flag, default=`2`. --- neofetch | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/neofetch b/neofetch index 1ddf7f38..8b8ff788 100755 --- a/neofetch +++ b/neofetch @@ -181,6 +181,12 @@ memory_percent="off" # gib: ' 0.98GiB / 6.79GiB' memory_unit="mib" +# Change memory output precision. +# +# Default: '2' +# Values: integer ≥ 0 +# Flag: --memory_precision +mem_precision=2 # Packages @@ -2806,10 +2812,10 @@ get_memory() { mem_label=TiB memory_unit_divider=$((1024 * 1024)) printf -v mem_used "%'.*f" \ - ${mem_precision:-2} \ + ${mem_precision} \ $(($mem_used / $memory_unit_divider)).$(($mem_used % $memory_unit_divider)) printf -v mem_total "%'.*f" \ - ${mem_precision:-2} \ + ${mem_precision} \ $(($mem_total / $memory_unit_divider)).$(($mem_total % $memory_unit_divider)) ;; @@ -2817,10 +2823,10 @@ get_memory() { mem_label=GiB memory_unit_divider=1024 printf -v mem_used "%'.*f" \ - ${mem_precision:-2} \ + ${mem_precision} \ $(($mem_used / $memory_unit_divider)).$(($mem_used % $memory_unit_divider)) printf -v mem_total "%'.*f" \ - ${mem_precision:-2} \ + ${mem_precision} \ $(($mem_total / $memory_unit_divider)).$(($mem_total % $memory_unit_divider)) ;; @@ -5088,6 +5094,7 @@ INFO: --song_shorthand on/off Print the Artist/Album/Title on separate lines. --memory_percent on/off Display memory percentage. --memory_unit (k/m/g/t)ib Memory output unit. + --memory_precision integer Change memory output precision. (≥0, default=2) --music_player player-name Manually specify a player to use. Available values are listed in the config file @@ -5297,6 +5304,7 @@ get_args() { "--music_player") music_player="$2" ;; "--memory_percent") memory_percent="$2" ;; "--memory_unit") memory_unit="$2" ;; + "--memory_precision") mem_precision="$2" ;; "--cpu_temp") cpu_temp="$2" [[ "$cpu_temp" == "on" ]] && cpu_temp="C" From ca13eb22e76c2dc4f2fabb3ceee5f27c428e6962 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C2=A9TriMoon=E2=84=A2?= Date: Mon, 31 Oct 2022 14:00:55 +0300 Subject: [PATCH 3/7] Update neofetch Fixing shellcheck warnings mentioned in https://github.com/dylanaraps/neofetch/pull/2225#issuecomment-1296876166 --- neofetch | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/neofetch b/neofetch index 8b8ff788..ef76628c 100755 --- a/neofetch +++ b/neofetch @@ -2812,22 +2812,22 @@ get_memory() { mem_label=TiB memory_unit_divider=$((1024 * 1024)) printf -v mem_used "%'.*f" \ - ${mem_precision} \ - $(($mem_used / $memory_unit_divider)).$(($mem_used % $memory_unit_divider)) + "${mem_precision}" \ + $((mem_used / memory_unit_divider)).$((mem_used % memory_unit_divider)) printf -v mem_total "%'.*f" \ - ${mem_precision} \ - $(($mem_total / $memory_unit_divider)).$(($mem_total % $memory_unit_divider)) + "${mem_precision}" \ + $((mem_total / memory_unit_divider)).$((mem_total % memory_unit_divider)) ;; gib) mem_label=GiB memory_unit_divider=1024 printf -v mem_used "%'.*f" \ - ${mem_precision} \ - $(($mem_used / $memory_unit_divider)).$(($mem_used % $memory_unit_divider)) + "${mem_precision}" \ + $((mem_used / memory_unit_divider)).$((mem_used % memory_unit_divider)) printf -v mem_total "%'.*f" \ - ${mem_precision} \ - $(($mem_total / $memory_unit_divider)).$(($mem_total % $memory_unit_divider)) + "${mem_precision}" \ + $((mem_total / memory_unit_divider)).$((mem_total % memory_unit_divider)) ;; kib) From d57463b0d3dedd1f5d722308735fc1737080119a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C2=A9TriMoon=E2=84=A2?= Date: Mon, 31 Oct 2022 14:15:44 +0300 Subject: [PATCH 4/7] Update neofetch Separating calculations as shown in https://github.com/dylanaraps/neofetch/pull/2225#issuecomment-1296882170 --- neofetch | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/neofetch b/neofetch index ef76628c..3618dd57 100755 --- a/neofetch +++ b/neofetch @@ -2811,17 +2811,20 @@ get_memory() { tib) mem_label=TiB memory_unit_divider=$((1024 * 1024)) - printf -v mem_used "%'.*f" \ - "${mem_precision}" \ - $((mem_used / memory_unit_divider)).$((mem_used % memory_unit_divider)) - printf -v mem_total "%'.*f" \ - "${mem_precision}" \ - $((mem_total / memory_unit_divider)).$((mem_total % memory_unit_divider)) ;; gib) mem_label=GiB memory_unit_divider=1024 + ;; + + kib) + mem_label=KiB + ;; + esac + + case $mem_label in + GiB|TiB) printf -v mem_used "%'.*f" \ "${mem_precision}" \ $((mem_used / memory_unit_divider)).$((mem_used % memory_unit_divider)) @@ -2830,11 +2833,10 @@ get_memory() { $((mem_total / memory_unit_divider)).$((mem_total % memory_unit_divider)) ;; - kib) + KiB) mem_used=$((mem_used * 1024)) mem_total=$((mem_total * 1024)) - mem_label=KiB - ;; + ;; esac memory="${mem_used}${mem_label:-MiB} / ${mem_total}${mem_label:-MiB} ${mem_perc:+(${mem_perc}%)}" From 619c9d222438bf40a557558ca35e453f62955280 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C2=A9TriMoon=E2=84=A2?= Date: Mon, 31 Oct 2022 14:29:18 +0300 Subject: [PATCH 5/7] Update neofetch Making calculations general purpose. --- neofetch | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/neofetch b/neofetch index 3618dd57..e487f8d9 100755 --- a/neofetch +++ b/neofetch @@ -2807,6 +2807,9 @@ get_memory() { [[ "$memory_percent" == "on" ]] && ((mem_perc=mem_used * 100 / mem_total)) + # Creates temp variables: memory_unit_divider, memory_unit_multiplier + memory_unit_divider=1 + memory_unit_multiplier=1 case $memory_unit in tib) mem_label=TiB @@ -2820,24 +2823,21 @@ get_memory() { kib) mem_label=KiB + memory_unit_multiplier=1024 ;; esac - - case $mem_label in - GiB|TiB) + # Uses temp variables from above: memory_unit_divider, memory_unit_multiplier + if test "$memory_unit_divider" -ge 1; then printf -v mem_used "%'.*f" \ "${mem_precision}" \ $((mem_used / memory_unit_divider)).$((mem_used % memory_unit_divider)) printf -v mem_total "%'.*f" \ "${mem_precision}" \ $((mem_total / memory_unit_divider)).$((mem_total % memory_unit_divider)) - ;; - - KiB) - mem_used=$((mem_used * 1024)) - mem_total=$((mem_total * 1024)) - ;; - esac + elif test "$memory_unit_multiplier" -ge 1; then + mem_used=$((mem_used * memory_unit_multiplier)) + mem_total=$((mem_total * memory_unit_multiplier)) + fi memory="${mem_used}${mem_label:-MiB} / ${mem_total}${mem_label:-MiB} ${mem_perc:+(${mem_perc}%)}" From c00568d413064ee30a352ce8e4a32195881be03c Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Tue, 1 Nov 2022 14:25:52 -0400 Subject: [PATCH 6/7] [F] Fix memory progress bar only displaying when unit is mib --- neofetch | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/neofetch b/neofetch index e487f8d9..88760809 100755 --- a/neofetch +++ b/neofetch @@ -2810,6 +2810,11 @@ get_memory() { # Creates temp variables: memory_unit_divider, memory_unit_multiplier memory_unit_divider=1 memory_unit_multiplier=1 + + # Keep a copy of the original megabyte values because progress bar need them + mu_mb="$mem_used" + mt_mb="$mem_total" + case $memory_unit in tib) mem_label=TiB @@ -2823,9 +2828,10 @@ get_memory() { kib) mem_label=KiB - memory_unit_multiplier=1024 + memory_unit_multiplier=1024 ;; esac + # Uses temp variables from above: memory_unit_divider, memory_unit_multiplier if test "$memory_unit_divider" -ge 1; then printf -v mem_used "%'.*f" \ @@ -2843,9 +2849,9 @@ get_memory() { # Bars. case $memory_display in - "bar") memory="$(bar "${mem_used}" "${mem_total}")" ;; - "infobar") memory="${memory} $(bar "${mem_used}" "${mem_total}")" ;; - "barinfo") memory="$(bar "${mem_used}" "${mem_total}")${info_color} ${memory}" ;; + "bar") memory="$(bar "${mu_mb}" "${mt_mb}")" ;; + "infobar") memory="${memory} $(bar "${mu_mb}" "${mt_mb}")" ;; + "barinfo") memory="$(bar "${mu_mb}" "${mt_mb}")${info_color} ${memory}" ;; esac } From 5012c996f2c52b1aafdceb885b64d877c1ccb9c8 Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Tue, 1 Nov 2022 14:26:01 -0400 Subject: [PATCH 7/7] [O] Fix shellcheck warnings --- neofetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neofetch b/neofetch index 88760809..d11331ee 100755 --- a/neofetch +++ b/neofetch @@ -2716,7 +2716,7 @@ get_memory() { pages_wired="$(vm_stat | awk '/ wired/ { print $4 }')" pages_compressed="$(vm_stat | awk '/ occupied/ { printf $5 }')" pages_compressed="${pages_compressed:-0}" - mem_used="$(((${pages_app} + ${pages_wired//.} + ${pages_compressed//.}) * hw_pagesize / 1024 / 1024))" + mem_used="$(((pages_app + ${pages_wired//.} + ${pages_compressed//.}) * hw_pagesize / 1024 / 1024))" ;; "BSD" | "MINIX")